Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

ulimit -a tells me I have a limit of 1024 open files, which is the default on my distro. Is there a way to show how many of these are currently used, or how many are remaining?

share|improve this question

1 Answer 1

up vote 4 down vote accepted

This limit apply per process.

One way to get the number of open files per process would be on Linux or Solaris:

for i in /proc/*/fd
do
    [ -r $i ] && printf "%6d : %d\n" $(basename $(dirname $i)) $(ls $i | wc -l)
done
share|improve this answer
    
If I start a shell, isn't this limit inherited to all child processes which I do further start from this shell? –  hirschhornsalz May 11 '11 at 14:00
    
Or more exactly, is the number of the remaining open files inherited? –  hirschhornsalz May 11 '11 at 14:05
    
No. Each subprocess starts with the full number of available fds. What is inherited is that limit, which can be reduced (or raised if you have the privileges). –  jlliagre May 11 '11 at 14:32

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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