
{{ $('Map tags to IDs').item.json.title }}
How to Use which and whereis Commands
In Linux, knowing where your executables and their associated documentation are located can streamline your command-line experience. The which
and whereis
commands are used to find out where binaries and resources are stored on your system. This tutorial will guide you through using these two commands effectively.
1. Using the which Command
The which
command helps you identify the location of executables in your system’s PATH. For example, to find out where the python3
executable is located, run:
which python3
This command will return the path of the python3
binary:
/usr/bin/python3
1.1. Multiple Executables
If you want to check multiple executables at once, you can provide a list:
which python3 node git
This will display the path of all specified binaries, if available.
2. Using the whereis Command
The whereis
command provides more comprehensive information than which
by finding the binary, source, and manual page files for a given command:
whereis python3
The output will typically look like this:
python3: /usr/bin/python3 /etc/python3 /usr/share/man/man1/python3.1.gz
This shows the paths to the binary, configuration files, and the manual page.
2.1. Finding Documentation
Using whereis
can help quickly locate documentation for many commands. For example:
whereis ls
This might return something like:
ls: /bin/ls /usr/share/man/man1/ls.1.gz
Here you see the location of the binary and its manual page.
3. Conclusion
By following this tutorial, you have learned to effectively use the which
and whereis
commands in Linux to locate executables and their associated documentation. These commands are invaluable for navigating the command line and managing your environment. Continue exploring other command-line tools to enhance your productivity and efficiency!