Linux: Find Out Open Files [ Descriptors ] Command

You can use the lsof (list open files) command in Linux to find out which files (also called descriptors) are open by a process. The lsof command displays a list of all open files and the processes that have them open.

To display the open files for a specific process, you can run the following command, where <pid> is the process ID of the process you’re interested in:

lsof -p <pid>

The output of the lsof command will show you the name of the file, its file descriptor, the process ID that has the file open, and other information such as the type of file and the current offset in the file.

For example, if you wanted to see the open files for the process with process ID 12345, you would run the following command:

lsof -p 12345

Note that the lsof command requires superuser privileges to run, so you may need to run it as root or with sudo.

Leave a Comment