Quick Links
Want to display the path of an executable Linux file? Several Linux commands, such aswhich,whereis,type -a, andcommand -v, can help you locate executable files and understand their origins in a simple and effective way.
Displaying the path of executable Linux files is useful for troubleshooting and verifying which version of a command is being used. It helps you check which version of the command is being executed when multiple versions or installations exist on the system. For example, if you have a system-wide and a user-installed version of a program, knowing the exact path helps you avoid unexpected behavior. It is particularly useful in environments where PATH variables are customized or modified.

Method 1: The which Command
Thewhich commandin Linux enables you to locate and display the exact path of an executable file. You can specify one or more files to find their paths. When you use the which command on Linux, it checks the directories listed in the PATH environment variable. It then shows the location of the first matching executable file it finds. However, you can run this command with the -a option to show all occurrences of an executable.
Linux’s which command returns three types of exit codes: 0 when all specified files are located and can run, 1 when at least one command is not executable, and 2 when an unrecognized option is used. The syntax for using the which command in Linux is shown below:

Here, fileName represents an executable file whose path you want to locate.
Example: Locating Executables on Linux with the which Command
Let’s run the which command to find the path of an executable file, Python3.10:
It retrieves all matching pathnames for the specified executable file:
Method 2: The whereis Command
Thewhereis command in Linuxreturns the locations of binary files (executables), source code files, and man pages for a given command. When you execute the whereis command, it browses standard system folders and shows the paths of the executable file and the manual pages related to the given command. The general structure for using the whereis command on Linux is shown below:
The whereis command can accept several options that are used to achieve a specific functionality. For example, you can execute whereis command with the -b option to search only binary files, -m for only manual pages, -B to specify the binary search path, and so on.

Example: Displaying the Path of an Executable With whereis
Firefox is an executable program available on Linux systems. You can use the whereis command to display its path:
In the following output, “/usr/bin/firefox` represents the path to the executable:

Method 3: The type Command in Linux
Thetype command in Linuxallows you to determine the nature of a command. For example, it tells whether the specified command is an alias, a built-in shell command, a function, or an external program stored on our system. You can also use the type command to check the path of a Linux executable file.
On Linux, type is a shell built-in command, and you can verify it by using:

The basic syntax of the type command to show the path of an executable file is shown below:
Example: Showing the Executable File Path with type
Let’s utilize the type command to show the path of Python, specifically python3.10:
The type command returns the first executable path for the specified command. To show all matching locations, run type with the -a flag:

Method 4: The command -v Command in Linux
The command -v command is a shell built-in command on Linux that retrieves the location of a command or shows whether it is available inyour system’s PATH. When you run this command, it shows detailed information indicating whether the given command is an executable file, a shell builtin, an alias, or a function.
To show the full path of an executable file, use the syntax:
Example: Showing Executable File Paths Using command -v
The following example uses command with the -v flag to show the path of Firefox:
The output shows that Firefox is an executable located at “/usr/bin/firefox”:
In Linux, several commands can help you find the path of an executable file. Each has its own specific use case, as discussed in this article. You can select the command that best suits your requirements to locate executable paths efficiently.
By practicing and mastering these Linux commands, you can quickly find the paths of your files and improve your workflow.