How to find location or path of a command
In our earlier posts we saw how to find the location of a file with locate command and find command. But how do we find the path of a command in Linux? For that purpose we use the following commands
which command
which command shows the complete path of a shell command. The command checks for the executable and shell scripts inside the directories defined in the environment variable PATH. The syntax for which command is
which [option] command_name
Examples
which java
which httpd
which httpd
Sample Output
/bin/java
/usr/sbin/httpd
/usr/sbin/httpd
whereis command
whereis command is used to find the binary, source and manual page files of a shell command. The syntax of whereis command is
whereis [option] command_name
Important options
-b | Search only for binaries |
-s | Search only for source |
-m | Search only for manuals |
Examples
whereis whereis
whereis -b whereis
whereis -m whereis
whereis -b whereis
whereis -m whereis
Sample Output
whereis: /usr/bin/whereis /usr/share/man/man1/whereis.1.gz
whereis: /usr/bin/whereis
whereis: /usr/share/man/man1/whereis.1.gz
whereis: /usr/bin/whereis
whereis: /usr/share/man/man1/whereis.1.gz
Comments
Post a Comment