1. List all Open Files with lsof Command> lsof
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
init 1 root cwd DIR 253,0 4096 2 /
init 1 root rtd DIR 253,0 4096 2 /
init 1 root txt REG 253,0 145180 147164 /sbin/init
init 1 root mem REG 253,0 1889704 190149 /lib/libc-2.12.so
FD column stands for File Descriptor, This column values are as below:-
cwd current working directory-
rtd root directory-
txt program text (code and data)-
mem memory-mapped fileTo get the count of open files you can use
wc -l with lsof like as follow:lsof | wc -l
2. List User Specific Opened Fileslsof -u alireza
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
sshd 1838 alireza cwd DIR 253,0 4096 2 /
sshd 1838 alireza rtd DIR 253,0 4096 2 /
#linux #sysadmin #lsof #wc #file_descriptor