what are differences between number of open_files and number of file_descriptors in linux ? I'm confused . The value in the /proc/sys/fs/file-max is for total file_descriptors or total open_files ? and in overall how can I calculate the total number of open_files for one pid and also total number of open_files in whole system ?

example : for mysqld proccess :

[root@agent]# lsof -p $(pidof mariadbd) | awk '{print $9}' | sort | uniq  | wc -l
[root@agent]# ll /proc/$(pidof mariadbd)/fd | wc -l

as you can see two values are different . why ?


1 Answer 1


/proc/PID/fd includes only actual open files and sockets.

lsof includes shared libraries as well.

  • which one is more important to monitor a linux server ?
    – Ali
    Nov 25, 2020 at 18:50
  • 1
    IMHO none of them are worth monitoring unless you're running out of RAM. 64bit Linux allows applications to have literally dozens of thousands of open files without any perceivable effect on performance. If you still want to monitor regardless, /proc/PID/fd is the metric to monitor. The number of open libraries should stay the same. Nov 26, 2020 at 0:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.