How to Find Programs with which, whereis and locate
Three commands answer Where is this program? which shows the path that runs when you type a command, whereis also finds manuals and sources, and locate searches a database of every file on the system in a flash.
Find a command's path with which
which command prints the location that would run, based on your PATH. If it prints nothing, the command is not installed or not in PATH.
Find binaries, manuals and sources with whereis
whereis searches standard locations for the binary, the man page and the source of a program at once.
Search everything fast with locate
locate looks up file names in a prebuilt database, so it is nearly instant across the whole system. Use a wildcard for partial names:
Keep locate's database fresh
locate only knows files that were in the database when it was last updated. Refresh it with updatedb (root), usually run daily by cron.
Which one should you use?
Typing a command that is missing: which. Checking a program's docs: whereis. Finding any file anywhere: locate. For a fully current search, use find. See the which, whereis and locate reference pages.
Keep learning
Related guides: How to Find Files and Directories with the Linux find Command · Linux Environment Variables: How to Set and Use Them · How to Run Commands as Root with sudo. Read all tutorials on the Learn Linux blog.