Finding out which files are being used by a process under Linux

I needed to find out which files a process was using. I used the following commands to do this.

The ps command to get the process id (PID) of the process.

$ ps -aef | grep

Then the lsof command to list the files being used by the process.

$ lsof -p

If you want to count the files being used, use the following command.

$ lsof -p  | wc -l

Have fun.

Leave a comment