Counting open files per user

In the event that your system is running out of file descriptors, or you simply want to know what your users are doing, you can review their count of open files by running this command:

lsof | grep ' root ' | awk '{print $NF}' | sort | wc -l

Of course, if you want to drop the count and show the actual processes, you can run:

lsof | grep ' root '

Printed from: http://rackerhacker.com/2007/09/26/counting-open-files-per-user/ .
© Major Hayden 2012.

2 Comments   »

  • brocknoland says:


    lsof | grep ' root ' | awk '{print $NF}' | sort | wc -l

    I am not sure what the awk,sort, and wc commands are being used for. Did you mean?


    lsof | grep ' root ' | awk '{print $NF}' | sort -u | wc -l

    Also of use would be:


    lsof -u username

  • brocknoland says:

    "I am not sure what the awk,sort, and wc commands are being used for."

    Sorry, I meant more just using -c on great or counting the lines directly.

RSS feed for comments on this post

Leave a Reply

 

  • Welcome! I started this blog as a way to give back to all of the other system administrators who have taught me something in the past. Writing these posts brings me a lot of enjoyment and I hope you find the information useful. If you spot something that's incorrect or confusing, please write a comment and let me know. Drop me a line if there's something you want to know more about and I'll do my best to write a post on the topic.
    -- Major Hayden

    Flattr this