Problem :
I want to list down all file names opened by init process. I know about /proc/PID/fd
directory. But that gives file descriptors only. How can I get file names from list of file descriptors?
Solution :
Use lsof to list open files of a process, in your case “init”:
$ sudo lsof -ln -p `pgrep init` COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME init 1 0 cwd DIR 8,1 4096 2 / init 1 0 rtd DIR 8,1 4096 2 / init 1 0 txt REG 8,1 36992 354775 /sbin/init init 1 0 mem REG 8,1 14768 354922 /lib/x86_64-linux-gnu/libdl-2.13.so init 1 0 mem REG 8,1 1599504 350331 /lib/x86_64-linux-gnu/libc-2.13.so init 1 0 mem REG 8,1 126232 354818 /lib/x86_64-linux-gnu/libselinux.so.1 init 1 0 mem REG 8,1 261184 354836 /lib/x86_64-linux-gnu/libsepol.so.1 init 1 0 mem REG 8,1 136936 354986 /lib/x86_64-linux-gnu/ld-2.13.so init 1 0 10u FIFO 0,14 0t0 3054 /run/initctl