Mastering Program Search in Linux: A Guide to Using whereis, find, and locate Commands


To locate a specific program in your system, the `whereis` command is often the most efficient choice. For instance, if you’re searching for the ‘ls’ program, simply enter:

whereis ls

This command will display results such as:

ls: /bin/ls /usr/share/man/man1p/ls.1p.gz /usr/share/man/man1/ls.1p.gz

Alternatively, you have other commands at your disposal, although they might be slower. One such option is the `find` command, which can be used as follows:

find / -type f -name "ls"

Another useful command is `locate`, which searches for any file names containing ‘ls’ in their path. The syntax is straightforward:

locate ls

However, `locate` tends to return a lengthy list of results, which can be challenging to navigate without filtering the output with tools like `grep` or using pagination commands such as `more` or `less`. This extra step is necessary for easier readability of the output.