How to find command location in Linux?

How to find command location in Linux and Unix

This is a small how to on finding your command location. Some times its required to find command location to use it as path is not set properly to /bin or /sbin or some other folder. And some times we install packages through scripts where the commands will be installed in a defined path other than /usr/bin or /usr/sbin etc.

command to check where the particular command is installed?

which command-name


which ls

Output: Share Image

root@surendra:/home/surendra# which ls

How about getting with other command along with manual pages?

whereis command-name


whereis ls


root@surendra:/home/surendra# whereis ls
ls: /bin/ls /usr/share/man/man1/ls.1.gz

some times we don’t know where the command is located but still we want to use it, at these times you can use which command to give entire path

`which ls`


$(which ls)

the above two are very much handy when writing shell scripts when you are not aware/sure where the command located. Please share your thoughts on how you avoid this situation.


Show your love by sharing this..!
Share on VKShare on StumbleUponShare on YummlyPrint this pageFlattr the authorShare on TumblrEmail this to someoneBuffer this pageShare on Google+Share on LinkedInShare on FacebookTweet about this on TwitterPin on PinterestShare on RedditDigg this
The following two tabs change content below.
My name is Surendra Kumar Anne. I hail from Vijayawada which is capital of south Indian state of Andhra Pradesh. I am a Linux evangelist who believes in Hard work, A down to earth person, Likes to share knowledge with others, Loves dogs, Likes photography. I work with ICE systems, Sydney as Sr. Consultant. You can contact me at surendra (@) linuxnix dot com.