Wednesday, October 10, 2012

In Linux, how to know how much space all directories and sub-dirs are using?


In linux, how to know how much space all directories and sub-dirs are using?

du -h --max-depth=1





du -h --max-depth=2
if you want to show for the sub directories one level below, too.



how to know how much disk space a directory takes in unix
http://www.thewebhostinghero.com/tutorials/linux-disk-usage-command.html
http://www.cyberciti.biz/faq/check-free-space/


Sometimes it’s useful to be able to find out how much disk space a directory is taking. While there are some web interfaces or desktop applications that allows you to do that, it’s always useful to know how it can be done through a command shell.

The DU Command

To find out how much space is being used, you can use the DU (Disk Usage) command. Here a few examples of the DU command usage.
Listing a disk space summary of directory
# du -sh [directory]
Listing the disk space used for a directory and its subdirectories, sorted by disk usage
# du -h [directory] | sort -rn
Take note that the “h” switch allows displays the disk usage in human readable format (ie. kylobytes, megabytes, etc.).




Linux / Unix: Checking Free Disk Space

by  on AUGUST 16, 2007 · 28 COMMENTS· last updated at AUGUST 16, 2007
Q. How do I check free disk space in Linux or UNIX operating system? I've migrated from Windows NT to Linux and looking forward to get more information about free disk space.
A. Both Linux and UNIX offers two commands for checking out free disk space:
(a) df command : Report file system disk space usage
(b) du command : Estimate file space usage

df command examples - to check free disk space

Type df -h or df -k to list free disk space:
$ df -h
OR
$ df -k
Output:
Filesystem             Size   Used  Avail Use% Mounted on
/dev/sdb1               20G   9.2G   9.6G  49% /
varrun                 393M   144k   393M   1% /var/run
varlock                393M      0   393M   0% /var/lock
procbususb             393M   123k   393M   1% /proc/bus/usb
udev                   393M   123k   393M   1% /dev
devshm                 393M      0   393M   0% /dev/shm
lrm                    393M    35M   359M   9% /lib/modules/2.6.20-15-generic/volatile
/dev/sdb5               29G   5.4G    22G  20% /media/docs
/dev/sdb3               30G   5.9G    23G  21% /media/isomp3s
/dev/sda1              8.5G   4.3G   4.3G  51% /media/xp1
/dev/sda2               12G   6.5G   5.2G  56% /media/xp2
/dev/sdc1               40G   3.1G    35G   9% /media/backup
he df utility displays statistics about the amount of free disk space on the specified file system or on the file system of which file is a part. Values are displayed in 512-byte per block counts. -H option is called as "Human-readable" output. It use unit suffixes: Byte, Kilobyte, Megabyte, Gigabyte, Terabyte and Petabyte in order to reduce the number of digits to four or fewer using base 10 for sizes i.e. you see 30G (30 Gigabyte).

du command examples

du shows how much space one ore more files or directories is using.
$ du -sh
103M
-s option summarize the space a directory is using and -h option provides "Human-readable" output.

GUI program

Above programs are good if GUI is not installed or you are working with remote system over ssh. Linux / UNIX comes with KDE and Gnome desktop system. You will find Free Disk Space Applet located under GUI menus.












No comments:

Post a Comment