Does Htop Show Open File Descriptors on Ubuntu
This article explains whether the htop process viewer can display the number of open files for a process on Ubuntu. While htop is a powerful tool for monitoring CPU and memory usage, it does not natively support displaying open file descriptor counts. The following sections clarify this limitation and provide the correct command-line alternatives to check this specific metric efficiently.
Htop Limitations
The standard version of htop found in Ubuntu repositories does not include a column for open files. The interface is designed to prioritize system resource metrics such as processor load, RAM consumption, and thread count. You cannot enable a file count column through the F2 setup menu or by editing the configuration file.
Check Open Files via Proc
The most direct method to view this information is by inspecting the proc filesystem. Each running process has a directory containing symbolic links to every open file descriptor. To count them, run the following command in the terminal, replacing PID with the actual process ID:
ls -l /proc/PID/fd | wc -l
This lists the contents of the file descriptor directory and counts the lines, providing the total number of open files.
Check Open Files via Lsof
You can also use the list open files utility known as lsof. This command offers detailed insights into files opened by specific processes. To get a count for a particular process, execute:
lsof -p PID | wc -l
Remember to subtract one from the final number to account for the header line output by the command. Both methods provide accurate data that htop cannot display.