How to View Process Executable Path in htop

This article provides a straightforward guide on how to locate and view the exact executable path of a running process using the htop interactive process viewer in Linux. You will learn the default view limitations, the specific keyboard shortcut required to expand the full command-line path, and how to search for specific processes efficiently.

The Challenge with Default htop Views

When you first open htop by typing htop in your terminal, you are presented with a real-time, dynamic list of running processes. By default, the Command column often truncates long paths or only shows the name of the executable (for example, apache2 or python3) rather than its absolute location on the filesystem (such as /usr/sbin/apache2).

When troubleshooting software configurations, identifying malicious processes, or debugging multiple instances of the same application, knowing the precise directory from which the binary is executing is crucial.

Step-by-Step: Revealing the Full Path

To see the complete, untruncated path of a process executable, use the following built-in htop features:

1. Toggle Full Command Lines (The ‘p’ Key)

By default, htop tries to balance readability by shortening paths. You can instantly toggle between the short program name and the full path with arguments by pressing the p key on your keyboard.

2. Scroll Horizontally for Long Paths

If an executable is buried deep within a nested directory structure, the full path might extend past the right edge of your terminal screen.

3. Filter or Search for the Process

If your process list is moving too quickly, you can isolate the specific application before inspecting its path:

Alternative: Accessing the Process Environment

If you need even more context about where a process is operating, htop allows you to look directly into its environment variables:

  1. Use the arrow keys to highlight the process in question.
  2. Press e to display the process’s environment variables.
  3. Look for the PWD (Present Working Directory) variable, which tells you the exact directory from which the process was launched. Press Esc to return to the main screen.