Questão de Linux Administration #019e3987
Which of the following commands can be used to locate programs and their corresponding man pages and configuration files?
dirname
which
basename
query
whereis
Explicação Oficial / Explicações da Comunidade
The whereis command is specifically designed to locate binary executables, source code, and manual page files for a given program. It searches in standard system directories (e.g., /bin, /sbin, /usr/bin, /usr/share/man) and displays the paths to the binary, man page, and configuration files if they exist. For example, whereis ls returns output like ls: /bin/ls /usr/share/man/man1/ls.1.gz.
How it Works
whereis uses a hardcoded list of directories (typically defined in the WHEREIS environment variable or compiled defaults) to search for files. It does not rely on a database like locate; instead, it performs a filesystem search in common locations. The command supports flags such as -b (binaries only), -m (man pages only), and -s (source code only).
Why the Correct Value is Right
The whereis command is the only option that can locate both programs and their corresponding man pages and configuration files. It is a standard utility on Unix-like systems and is part of the GNU coreutils.
Why the Incorrect Values are Wrong
dirnameextracts the directory path from a given file path (e.g.,dirname /usr/bin/lsreturns/usr/bin). It does not search for programs or man pages.whichlocates the executable file associated with a command by searching the user's$PATH. It only shows the binary, not man pages or configuration files.basenamestrips directory and suffix from a file path (e.g.,basename /usr/bin/lsreturnsls). It does not perform any searching.queryis not a standard Linux command for locating programs or documentation. It may be used in specific contexts (e.g., RPM package queries withrpm -q), but it does not serve the general purpose described in the question.