which/whereis differences
What's the difference between which
and whereis
?
How about learning about whereis
and which
using whatis
?
$ whatis which
which (1) - shows the full path of (shell) commands
$ whatis whereis
whereis (1) - locate the binary, source, and manual page files for a command
Basically, whereis
searches for "possibly useful" files, while which
only searches for executables.
I rarely use whereis
. On the other hand, which
is very useful, specially in scripts. which
is the answer for the following question: Where does this command come from?
$ which ls
/bin/ls
$ whereis ls
ls: /bin/ls /usr/share/man/man1p/ls.1p.bz2 /usr/share/man/man1/ls.1.bz2
whereis
searches the standard *nix locations for a specified command.
which
searches your user-specific PATH (which may include some of the locations whereis searches, and may not include others - it might also include some places that whereis
doesn't search if you'd added to your PATH)