How to see number of open file handles per process?

Most active processes use one or more file descriptors. These descriptors are an internal representation to the kernel of an opened file. Also opened sockets for network connections are counted as opened files. To see the correct number of opened files per process, we can leverage the /proc file system to provide this information.

Examples

find /proc/12345/fd -type l | wc -l

Count the number of file descriptors for process ID 12345

This find statement looks in the file descriptors directory belonging to a particular process ID (PID). It lists the available symlinks and gets counted using the wc command.

Sample output

7

Recently updated at April 27, 2023

Do you like this page? Share it with others or help us make it better

Yes!

Share with friends:
Share on Twitter