To list the open files for a process on a Linux or Unix system, you can use the lsof
command.
For example, to list the open files for a process with the process ID (PID) 123
, you can use the following command:
lsof -p 123Source:www.lautturi.com
This will show a list of all the open files for the process with PID 123
.
You can also use the lsof
command to list the open files for a specific user or a specific program. For example, to list the open files for the user user1
, you can use the following command:
lsof -u user1
To list the open files for the program program1
, you can use the following command:
lsof -c program1
You can also use the /proc
filesystem to list the open files for a process. The /proc
filesystem is a virtual filesystem that provides information about the running processes on the system.
For example, to list the open files for a process with PID 123
, you can use the following command:
ls -l /proc/123/fd
This will show a list of all the open files for the process with PID 123
. The fd
directory in the /proc
filesystem contains a symbolic link for each open file descriptor for the process.
Note: To list the open files for all processes, you can use the
lsof
command without any options.
lsof