Which command checks for broken symbolic links in a directory?

Prepare for the Linux Professional Institute Certification Level 1. Use flashcards and multiple choice questions, complete with hints and explanations. Enhance your understanding and get ready to ace the exam!

The command that effectively checks for broken symbolic links in a directory is the one that employs the find utility in conjunction with specific test conditions. By using find . -type l ! -exec test -e {} \; -print, it accomplishes a couple of tasks:

  1. The find command starts searching from the current directory (denoted by the dot .).
  1. The option -type l restricts the search to symbolic links only.

  2. The expression ! -exec test -e {} \; looks for symbolic links that do not point to valid targets. Here, test -e {} checks if the symbolic link points to a valid file or directory; the ! negates this check, thus identifying broken links.

  3. If a broken link is found, -print will output the path of that link.

This method is both effective and precise for identifying broken symbolic links, making it the correct answer to the posed question. In contrast, the other options either do not provide functionality for checking broken links or are simply not valid commands for this particular task.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy