There are handy commands for finding out where things are on your Linux systrm.
which, whereis, locate. and find.
find will find just about any file. But you have to know at least part of the name.
Because it does the search in real time, it can take a few seconds to return the results.
It also works best if you know the path. You don't need the whole path, the more you know the
faster it works because the search is narrowed down.
Find works like this.
example
locate works a litle differently, it uses a mini-database to find where files are.
It's faster than find, but only works if the file is in the database. Many rpm, deb and other packages
will sometimes put the command in the database when they are installed. The default commands
are usually already there. It has been my experience that binaries installed using snap, appImage and
flatpak are generally not added to the database.
Using locate is pretty straight forward also
to update the locate database
which is generally for only finding executable binary files in your $PATH.
It's not really for text files in your home directory.
How to use which.
example
whereis is kind of like which in that it's mostly for binaries in your $PATH, however it gives a little
more information than which. It will tell where the binary is, the source code (if you have it loaded as a package)
and where the man pages are.
How to use whereis.
example
which, whereis, locate. and find.
find will find just about any file. But you have to know at least part of the name.
Because it does the search in real time, it can take a few seconds to return the results.
It also works best if you know the path. You don't need the whole path, the more you know the
faster it works because the search is narrowed down.
Find works like this.
Code:
find /path/to/search -name "filename"
example
Code:
find /home/user -name "*.txt"
locate works a litle differently, it uses a mini-database to find where files are.
It's faster than find, but only works if the file is in the database. Many rpm, deb and other packages
will sometimes put the command in the database when they are installed. The default commands
are usually already there. It has been my experience that binaries installed using snap, appImage and
flatpak are generally not added to the database.
Using locate is pretty straight forward also
Code:
locate myfile.txt
to update the locate database
Code:
sudo updatedb
which is generally for only finding executable binary files in your $PATH.
It's not really for text files in your home directory.
How to use which.
Code:
which command
example
Code:
which python
whereis is kind of like which in that it's mostly for binaries in your $PATH, however it gives a little
more information than which. It will tell where the binary is, the source code (if you have it loaded as a package)
and where the man pages are.
How to use whereis.
Code:
whereis command
example
Code:
whereis gcc
Last edited: