Go Back   Linux Forums by TotalPenguin! Get linux Help! > Linux > Tutorials, Guides and Tips

Tutorials, Guides and Tips Member submitted guides, tips, tricks and howtos.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-20-2008, 01:40 PM
Senior Member
 
Join Date: Jan 2007
Posts: 133
Wanch is on a distinguished road
Default Largest directory and/or file

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:

Code:
ls -lsR | sort -n
You can remove the "R" to remove the recursive function (which is a bit annoying):

Code:
ls -ls | sort -n
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.
Reply With Quote

Sponsored Links
Reply

Tags
largest directory, largest file

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Mount .cue/.bin file? Off Linux General 1 07-08-2008 01:39 PM
Sync a Directory ptt3 Linux General 1 07-01-2008 02:50 PM
Directory listing Valor Linux Web Server 1 05-24-2008 04:51 PM
tar entire directory Prog Linux General 3 07-20-2007 06:37 PM
Howto: Find the largest directory/file in a directory ptt3 Linux General 4 05-28-2007 10:08 PM


All times are GMT. The time now is 02:23 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.