Here are three useful commands to find the files and directories using the most disk space under Linux…

  1. 50 largest files…

    find / -path '/proc' -prune -o -size +1000k -printf '%s %p\n' | sort -k1 -g -r | head -50

  2. 50 largest directories (w/o files in subdirectories)…

    du -kS / | sort -k1 -g -r | fgrep -v '/proc' | head -50

  3. 50 largest directories (with files in subdirectories)…

    du -k / | sort -k1 -g -r | fgrep -v '/proc' | head -50

This post is not intended to be a tutorial on the Linux shell and how to use each of the referenced commands; instead, these are snippets I’ve found useful over the years to analyze disk space.

Here is some of the output from running the first command above on one of our servers…

236272746 /root/sb_opt_2007_09_16.tar.gz
123542817 /opt/sb/sb-ext.zip
116717016 /home/twall/sb-ext.tar.gz
116717016 /home/kjohn/sb-ext.tar.gz
74840792 /home/kjohn/ib-ext.tar.gz
74840708 /home/twall/ib-ext.tar.gz
64638719 /root/jdk-6u3-linux-i586-rpm.bin
56835774 /root/jdk-6u3-linux-i586.rpm
54337152 /usr/lib/locale/locale-archive
48276960 /usr/java/jdk1.6.0_03/jre/lib/rt.jar
48117502 /root/install/jdk-1_5_0_12-linux-i586.rpm
39996663 /usr/java/jdk1.5.0_12/jre/lib/rt.jar
29923467 /root/sb_ext.tar.gz
24114161 /root/sb_cvsroot_2007_09_18.tar.gz
21577776 /usr/lib/libgcj.so.7.0.0
19673088 /var/lib/rpm/Packages
19077102 /root/install/MySQL-server-5.0.45-0.i386.rpm
18874368 /var/lib/mysql/ibdata1
18671152 /usr/java/jdk1.6.0_03/src.zip

Note that these commands can take a long time to run and generate a lot of load — be careful running these on production systems.

Bookmark at:
StumbleUpon | Digg | Del.icio.us | Dzone | Newsvine | Spurl | Simpy | Furl | Reddit | Yahoo! MyWeb
One Response to “Find the Files and Directories Using the Most Disk Space under Linux”
  1. Find the Files and Directories Using the Most Disk Space under Linux…

    Here are three useful commands to find the files and directories using the most disk space under Linux……

Leave a Reply