Last Updated: February 25, 2016
· dpashkevich

Get a list of files opened by a process

Here's a handy snippet to get all file descriptors opened by a particular process in a linux system:

[sudo] ls -l /proc/`pgrep <PROGRAM NAME>`/fd

The pgrep command returns a PID of a running program by its name. If you're trying to use it for scripts (e.g. node myApp.js), try to add the -f option to search by entire run commandline, not just the executable name (which would be just node in my example):

[sudo] ls -l /proc/`pgrep -f myApp`/fd
Say Thanks
Filed Under