Top 15 processes with the largest number of open files

lsof +c 15 | awk '{print $1}' | sort | uniq -c | sort -rn | head
See the summary.
Sample Output
   5993 chromium-browse
   1466 gwibber-service
   1148 xfce4-terminal
    765 bash
    725 ssh
    721 apache2
    314 pidgin
    298 thunderbird-bin
    295 gtk-window-deco
    288 firefox

1
By: SEJeff
2012-05-25 16:31:46

These Might Interest You

  • List all open files of all processes. . find /proc/*/fd Look through the /proc file descriptors . -xtype f list only symlinks to file . -printf "%l\n" print the symlink target . grep -P '^/(?!dev|proc|sys)' ignore files from /dev /proc or /sys . sort | uniq -c | sort -n count the results . Many processes will create and immediately delete temporary files. These can the filtered out by adding: ... | grep -v " (deleted)$" | ... Show Sample Output


    1
    find /proc/*/fd -xtype f -printf "%l\n" | grep -P '^/(?!dev|proc|sys)' | sort | uniq -c | sort -n
    flatcap · 2015-08-18 17:58:21 0
  • Reduce the number of keystrokes it takes to open a file in vim. First of all, you just need to type "v", which is less than half the number of characters (!), and second-of-all, you only need to enter a substring of the file you want to open. For example, if you want to open the file, homework.txt, then type "v hom" to open it. Good tip is to use the lowest unique substring, otherwise you'll open multiple files in different buffers (which is sometimes desirable). Use Ctrl-^ to switch between buffers.


    0
    function v { if [ -z $1 ]; then vim; else vim *$1*; fi }
    kFiddle · 2009-04-11 23:06:43 2
  • I think I could cut down the number of pipes here, any suggestions? Show Sample Output


    4
    lsof | awk '{print $1}' | sort | uniq -c | sort -rn | head
    sud0er · 2009-02-19 19:45:09 0
  • Will work with filenames with spaces inside. Will not break in case of someone making directory that matches *.pm. And sorts from largest. Where largest is file size, not line count.


    0
    find . -type f -name '*.pm' -printf '%6s %p\n' | sort -nr | head -n 50
    depesz · 2011-02-09 16:19:11 0

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: