User Tools

Site Tools


linux:fdprocesses

PROCESSES AND FILES DESCRIPTORS IN LINUX

  • To see every process on the system using BSD syntax:

$ ps auxw

  • Finds out open files associated with a process (PID: XXXX)

lsof | grep "XXXX"
lsof | grep "XXXX" | wc -l # do a count

  • See the file descriptors for a process (identify by PID:XXXX)

ls -l /proc/XXXX/fd/

  • Maximum number of file descriptors

cat /proc/sys/fs/file-max
309495

  • Number of file descriptors used

cat /proc/sys/fs/file-nr
5888    0       309495

Example:
5888 - total allocated file descriptors
0 - total free allocated file descriptors
309495 - maximum number of file descriptors allowed on the system (given also by cat /proc/sys/fs/file-max)

  • Number of open files on the system

lsof | wc -l

Note: the difference between open files on the system and the number of file descriptors, is explained by the fact that some of the open files do not have file descriptors associated with them - libraries, current working directories and the bash program itself. Libraries for some process are shown in /proc/XXXX/maps and current working directory in proc/XXXX/cwd

linux/fdprocesses.txt · Last modified: 2013/03/16 17:40 (external edit)