How to find absolute path of command on Linux / Unix : which command

In Linux and Unix systems, commands are executable files. The commands may be specific with user environment.We can set the absolute path of specific command as per user in environment.If we require the information, to get the absolute path of command. In that case we will use which command.

To find the absolute path of command in Linux/Unix system, we use which command.


which command-name


which executable-file-name

Note: The echo $PATH command will show the directory path. The which command, locate the command from these directories.

For example:

root@tuxworld:/# echo $PATH

Example : In this example,we will find the absolute path of useradd command.
The output from which command is showing the absolute path.

root@tuxworld:/# which useradd

Print multiple command’s absolute path

We can use multiple arguments in which command. Hence,we can show two or more executable files absolute path on terminal.


which command-1 command-2 command-N

Example: In this example,we are finding the absolute path of ls,chown,chgrp and usermod command.

root@tuxworld:/# which ls chown chgrp usermod

print all matching pathnames of each argument

To print all matching pathnames of each argument,we use -a option with arguments i.e command name.


which -a argument

Example: In this example, we are searching absolute path of echo command

root@tuxworld:/# which -a echo






Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.