Linux – Restrict lsof Output to Physical Files Only

linuxlsof

How do I tell lsof I need to list only physical files (not sockets, not TCP/IP connections, only physical files)?

Best Answer

Just looked through some man pages, it appears you use the command:

sudo lsof /

This will list all open files in the / directory, which is everything on a Linux filesystem. Just tested and it shows only REG and DIR.

More examples:

lsof -a -d 0-999 -c <command name> /
lsof -a -d 0-999 -p <pid> /

0-999 limits it to files with a file descriptor number.