+ Reply to Thread
Results 1 to 2 of 2

Thread: Largest directory and/or file

  1. #1
    Wanch Guest

    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.

  2. CODECALL Circuit advertisement

     
  3. #2
    whwmia's Avatar
    whwmia is offline Newbie
    Join Date
    Aug 2009
    Posts
    24
    Rep Power
    0

    Re: Largest directory and/or file

    Thanks ! Nice one !

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. File and Directory security
    By atrip25 in forum PHP Development
    Replies: 7
    Last Post: 11-30-2009, 01:42 PM
  2. Largest file or directory
    By Lop in forum Computer Software/OS
    Replies: 7
    Last Post: 02-13-2008, 11:03 AM
  3. Replies: 1
    Last Post: 01-01-2008, 02:27 PM
  4. Can't Delete Directory/File
    By Chan in forum Computer Software/OS
    Replies: 5
    Last Post: 12-21-2007, 08:36 AM
  5. Howto: Find the largest directory/file in a directory
    By ptt3 in forum Linux/Unix General
    Replies: 4
    Last Post: 05-28-2007, 02:08 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts