Home » Linux » Basic Commands » Use “which” to Check Full Path of Linux Commands

Use “which” to Check Full Path of Linux Commands

The “which” command returns the pathnames of the files (or links) which would be executed in the current environment. It does this by searching the PATH for executable files matching the names of the arguments.

For example, when you type “ls” command in terminal to check the list of files, the actual binary which is executed on the terminal is “/usr/bin/ls” . so if you want to check where is the exact binary executed when you type command, you can type “which command_name” and you will get the active binary path.

$ which ls

Syntax of which Command


You can also provide more than one arguments to the which command:

$ which top size

If more than one matches are found in the directories listed in the PATH path variable, “which" will print only the first one. To print all matches, use the -a option:

$ which -a ls
#Shorts Check if a directory exists...
#Shorts Check if a directory exists - Ansible module stat

Leave a Comment