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
/usr/bin/ls

Syntax of which Command

which [OPTIONS] FILE_NAME

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

$ which top size
/usr/bin/top
/usr/bin/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
/usr/bin/ls
/bin/ls
How to Get the File Path of any Fil...
How to Get the File Path of any File or Folder on Mac OS

Leave a Comment