The difference between which and whereis in Ubuntu
which and whereis are commonly used commands in Linux systems to find the location of a specific command or file. In Ubuntu, these two commands are used as follows:
- which command
The which command is used to find the location of the executable file in the PATH path.
Example:
which ls
Output:
/bin/ls
explain:
This command finds the location of the ls command and outputs the result as /bin/ls.
- whereis command
The whereis command is used to find the location of specified files, including binary files, source files, and help documents.
Example:
whereis ls
Output:
ls: /bin/ls /usr/share/man/man1/ls.1.gz
explain:
This command finds the location of the ls command, and the output results are /bin/ls and /usr/share/man/man1/ls.1.gz (the location of the help document).