Which command would search for a file named motd under the /etc directory?

Prepare for the Red Hat Certified Systems Admin Exam EX200. Enhance your skills with interactive quizzes, flashcards, and detailed explanations. Ace your certification exam today!

Multiple Choice

Which command would search for a file named motd under the /etc directory?

Explanation:
Searching for a file by name within a specific directory is done with the find command, providing the starting directory and a name pattern. The best choice is to start at /etc and look for the exact name motd, which is exactly what the command find /etc -name motd does. It traverses /etc and all subdirectories, returning any files that match that exact name. The other options don’t fit this goal. rpm -qd motd queries which files are owned by a package named motd, not a filesystem search for a file by name. locate motd uses a prebuilt database and isn’t restricted to /etc, and may miss recent changes if the database isn’t updated. whereis motd searches for standard program locations (binaries, sources, and man pages) for a command or utility named motd, not for arbitrary files within a specific directory.

Searching for a file by name within a specific directory is done with the find command, providing the starting directory and a name pattern. The best choice is to start at /etc and look for the exact name motd, which is exactly what the command find /etc -name motd does. It traverses /etc and all subdirectories, returning any files that match that exact name.

The other options don’t fit this goal. rpm -qd motd queries which files are owned by a package named motd, not a filesystem search for a file by name. locate motd uses a prebuilt database and isn’t restricted to /etc, and may miss recent changes if the database isn’t updated. whereis motd searches for standard program locations (binaries, sources, and man pages) for a command or utility named motd, not for arbitrary files within a specific directory.

Subscribe

Get the latest from Passetra

You can unsubscribe at any time. Read our privacy policy