In this guide, we will go through how to find path to a command in Linux. We will look at the most common commands used in Linux such as which, whereis and type to find path to a command.
which Command
- The which command is installed by default on most Linux systems. To get the path to a command use which as shown below.
which vlc
- You can output all similar path names by including the -a option as shown below.
which -a vlc
Sample output
/usr/bin/vlc
/bin/vlc
whereis Command
- The whereis command finds the location of a specific command’s binaries, source and manual page.
whereis vlc
Sample output
vlc: /usr/bin/vlc /usr/lib/x86_64-linux-gnu/vlc /usr/share/vlc /usr/share/man/man1/vlc.1.gz
- To show the source use the
-s
option.
whereis -s vlc
- To show manual use the
-m
option
whereis -m vlc
Sample output
vlc: /usr/share/man/man1/vlc.1.gz
type Command
- The type command can determine whether a target is built-in, a function, an alias, or an external executable in addition to displaying the path of a Linux command. Print the path of any command using the type like the example below.
type -P pwd
Sample output
/usr/bin/pwd
- Remove the
-P
option to view the command description
type pwd
Sample output
pwd is a shell builtin
- To show the command description executable type and its location using the -a option.
type -a pwd
Sample output
pwd is a shell builtin
pwd is /usr/bin/pwd
pwd is /bin/pwd
- That concludes our guide on how to find path to a command in Linux.
Read more about whereis command
Read more about type command