how to list all the files opened by a particular PID ?
To list all the files opened by a particular process identified by its Process ID (PID), you can use the lsof command or look into the /proc filesystem on Unix-like systems.
Using lsof
The lsof (List Open Files) command is a utility that provides detailed information about files opened by processes. To list all the files opened by a specific PID, you can use:
lsof -p <PID>Replace <PID> with the actual process ID.
Using /proc Filesystem
You can also find the information in the /proc directory, which contains information about processes.
- Navigate to the directory for the specific PID:
cd /proc/<PID>/fd- List the files:
ls -lEach entry in this directory is a symbolic link to an open file descriptor for the process. The links will show the files that are opened by the process with the specified PID.
Example
If the PID is 1234, you can use either of the following methods:
- Using
lsof:
lsof -p 1234- Using
/procfilesystem:
cd /proc/1234/fd
ls -lBoth methods will provide you with a list of files opened by the process with PID 1234.
