In Linux, how can I get a list of files currently open in program X?
(Specifically, I'm on Fedora, and the program is Zend Studio, but I assume there's a general answer.)
In Linux, how can I get a list of files currently open in program X?
(Specifically, I'm on Fedora, and the program is Zend Studio, but I assume there's a general answer.)
Use e.g. lsof
("list open files") and filter the output, or use the -c programX
option to restrict it to files opened by programX. This expression can be a wildcard.
Install the program lsof
if you haven't already. Get the pid of the running program. Run lsof -p [pid]
.
You can find symbolic links to the actual files in /proc/PID/fd
where PID
is the process ID.
ls -l /proc/<zend studio's pid>/fd
will print a list of file descriptors. Those that map to files that were opened through open()
will be symlinks to the file path used to open them.
lsof -p [PID]
Or, to get the PID in one go
lsof -p `pgrep [PROG_NAME]`
Or, even simpler
lsof -c [PROG_NAME]