6 ms·
> The lsof command is used to list the information about running processes in the system and can also be used to list the file descriptor under a specific PID.
by shmerl 3y ago
> The lsof command is used to list the information about running processes in the system and can also be used to list the file descriptor under a specific PID.
> For that, use the “-d” flag to specify a range of file descriptors, with the “-p” option specifying the PID. To combine this selection, use the “-a” flag.
> $ lsof -a -d 0-2147483647 -p 11472
That works. A nicer way to do it:
htop > F3 (search by name to find the process) > Enter (to select) > L (open the list of file descriptors) > F4 (filter by resource name)
It lists all open files and other resources of the process.
- kristjansson 3y agoI use htop at least once a day and had no idea it could do that. Thanks!
- shmerl 3y agoYou're welcome! I found that after KDE replaced ksysguard with system monitor. The former could list all open files of the proecss, but the latter can't. So I was digging for some good tool and found this obscure htop feature :) It's documented in man htop btw.
- seodisparate 3y agoIsn't there `proc` on Linux systems? Get the pid of the process you want to inspect, and while its running, execute `ls -lh /proc/<pid>/fd/`. It will list the open file descriptors for that process.
- shmerl 3y agoSure, that's one of the more manual methods OP mentions too. Above one is just nicer.