After search I found two commands to find the largest directory (in a directory) and the largest file.
Largest Directory
Code:
# du -ch --max-depth 2 /
which will output something like this:
Code:
27M /usr/include
24K /usr/X11R6
137M /usr/bin
37M /usr/sbin
19M /usr/libexec
2.3G /usr/local
3.7G /usr
60G /
You can change the dept and the dir to scan:
Code:
# du -ch --max-depth 1 /usr
which will output:
Code:
596M /usr/share
1.6M /usr/kerberos
550M /usr/lib
8.0K /usr/games
76K /usr/doc
12K /usr/etc
87M /usr/src
160K /usr/man
27M /usr/include
24K /usr/X11R6
138M /usr/bin
37M /usr/sbin
19M /usr/libexec
2.3G /usr/local
3.7G /usr
3.7G total
Largest File
This command is fairly simple and just lists recursively (all directories) files and then sorts them by size:
You can remove the "R" to remove the recursive function (which is a bit annoying):
Which will output:
Code:
total 284
4 drwx------ 2 root root 4096 Jul 28 09:59 portsentry/
4 drwxr-xr-x 2 root root 4096 Jul 28 09:57 proftpd/
4 drwxr-xr-x 3 root root 4096 Jun 2 13:04 profiles/
4 drwxr-xr-x 52 root root 4096 Aug 20 08:39 cpanel/
4 drwxr-xr-x 5 named named 4096 Aug 20 06:03 named/
4 lrwxrwxrwx 1 root root 10 Jun 2 12:23 mail -> spool/mail/
4 -rw-r--r-- 1 root root 5 Jul 28 09:57 proftpd.pid
8 drwxrwxr-x 5 root lock 4096 Aug 20 04:02 lock/
8 drwxr-xr-x 12 root root 4096 Aug 20 00:01 log/
8 drwxr-xr-x 14 root root 4096 Jun 2 13:32 spool/
8 drwxr-xr-x 22 root root 4096 Aug 20 05:45 run/
8 drwxr-xr-x 22 root root 4096 Aug 8 12:34 lib/
8 drwxr-xr-x 25 root root 4096 Jun 19 15:07 ./
8 drwxr-xr-x 28 root root 4096 Jul 28 09:57 ../
8 drwxr-xr-x 2 root root 4096 Jun 2 12:25 account/
8 drwxr-xr-x 2 root root 4096 Mar 17 2007 cvs/
8 drwxr-xr-x 2 root root 4096 Mar 29 2007 games/
8 drwxr-xr-x 2 root root 4096 Mar 29 2007 local/
8 drwxr-xr-x 2 root root 4096 Mar 29 2007 nis/
8 drwxr-xr-x 2 root root 4096 Mar 29 2007 opt/
8 drwxr-xr-x 2 root root 4096 Mar 29 2007 preserve/
8 drwxr-xr-x 2 root root 4096 May 19 2007 racoon/
8 drwxr-xr-x 3 root root 4096 Jun 2 12:25 db/
8 drwxr-xr-x 3 root root 4096 Jun 2 12:25 empty/
8 drwxr-xr-x 3 root root 4096 Jun 2 12:25 yp/
8 drwxr-xr-x 8 root root 4096 Jun 2 12:27 cache/
104 drwxrwxrwt 9 root root 98304 Aug 20 08:38 tmp/
I thought I would share this with everyone.