I have a daemon process and I want to know what files it has open (and ideally what its CWD is). Is there any shell command that can tell me that?
Linux – How to tell what files a process has open
fileslinuxprocessUbuntu
Related Topic
- Linux Bash – How to Sort du -h Output by Size
- Windows – How to free up a port being held open by dead process
- Linux – How to Get PID of Just Started Process
- Monitor open process files on linux (real-time)
- Linux – How to run command as user who has /usr/sbin/nologin as Shell
- Linux Web Server – Proper Permissions for Website Files and Folders
- How to find what process for a particular user is accessing files on a share
Best Answer
I do love
lsof
, but I think it's overkill for a simple question like this. The/proc
filesystem contains everything you want to know. Perhaps an example would be best:So as you can see, the
/proc/$PID
directory contains a symlink called "cwd" that links the the CWD of the process. The same is true for the open filedescriptors listed in/proc/$PID/fd
.The
/proc/$PID
hierarchy contains a wealth of information about all running processes. Worth poking around in!