24

There's a bzip2 process running in the background and I have no idea where it came from. It's eating up a lot of resources. Can I do a reverse lsof to see which files are being accessed by this process?

I've suspended the process for the time being.

2 Answers 2

43

I'm not sure why that'd be a "reverse lsof" -- lsof does exactly that. You can pass it the -p flag to specify which PIDs to include/exclude in the results:

$ lsof -p $(pidof bzip2)
2
  • 3
    Reverse from lsof /path/to/file (which I guess is the mode of operation Pieter is used to). Commented Sep 30, 2011 at 23:35
  • 1
    Note that if you have existing filters to lsof, you can use -a to AND them instead of ORing them: lsof -a -i TCP -p 12345.
    – wchargin
    Commented Sep 20, 2019 at 0:28
7

In the /proc/ directory you can find details of the running processes, in separate directories, by their PID. Their file descriptors are enumerated in the fd/ sub-directory:

ls -l /proc/$(pidof -s bzip2)/fd/

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .