$ ps auxw
lsof | grep "XXXX" lsof | grep "XXXX" | wc -l # do a count
ls -l /proc/XXXX/fd/
cat /proc/sys/fs/file-max 309495
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)
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