How to View Open Files for a Process in htop

This article provides a quick guide on how to inspect the open files and network sockets associated with a specific, highlighted process using the htop interactive process viewer in Linux. By utilizing built-in shortcuts and integrating with the lsof utility, htop allows system administrators and developers to troubleshoot file locks, monitor resource usage, and analyze process behavior directly from the terminal interface.

Prerequisites for Viewing Open Files

Before using this feature within htop, ensure that the lsof (LiSt Open Files) utility is installed on your Linux system. htop relies on this external command to fetch and display the detailed list of files a process has opened.

You can install it via your package manager if it is missing:

Step-by-Step Guide to Using the lsof Shortcut

  1. Launch the utility by typing htop in your terminal.
  2. Use the Up and Down arrow keys to navigate through the process list and highlight the specific target process.
  3. Press the l key (lowercase L) on your keyboard.

htop will immediately open a separate, dedicated screen displaying every open file descriptor, regular file, library, and network socket currently held by that process.

Once inside the open files view, you can manage and inspect the data using the following controls: