Linux- Finding the size of a directory, finding the disk free space

$ du // This gives you a list of directories that exist in the current directory along with their sizes.
$ du app/ // This gives you a list of directories that exist in the specified directory app/ along with their sizes. 

$ du -h //  Better output, '-h' stands for human readable format. So the sizes of the files / directories are this time suffixed with a 'k' if its kilobytes and 'M' if its Megabytes and 'G' if its Gigabytes.

$ du -ah // Lists file size also and in human readable format. 

$ du -c // This gives only total size of the directories and the grand total.

$ du -ch | grep total  // This gives the total size 

$ df 
$ df   // This shows the free space in kilobytes 
Filesystem           1K-blocks      Used Available Use% Mounted on
rootfs                40316280   5077616  34829228  13% /
udev                   1474708         0   1474708   0% /dev
tmpfs                  1482684      9024   1473660   1% /dev/shm
tmpfs                  1482684       712   1481972   1% /run
/dev/sda6             40316280   5077616  34829228  13% /
tmpfs                  1482684         0   1482684   0% /sys/fs/cgroup
tmpfs                  1482684         0   1482684   0% /media
/dev/sda8             46003208   9172500  34493840  22% /home
/dev/sda6             40316280   5077616  34829228  13% /tmp
/dev/sda6             40316280   5077616  34829228  13% /var/tmp
/dev/sda8             46003208   9172500  34493840  22% /home

$ df -h // With human readable format 

$ df -h | grep /dev/sda8 
/dev/sda8              44G  8.8G   33G  22% /home
/dev/sda8              44G  8.8G   33G  22% /home
$ df -h | grep /dev/sda8 | cut -c 41-43 // This command gives the usage percentage of /dev/sda8 
22%
22%

Reference: http://www.codecoffee.com/tipsforlinux/articles/22.html 
Advertisements

Author: Abhi

Hi, this is Abhilash - Senior Programmer Analyst at CoMakeIT, specialised on web programming. Mainly working on Ruby On Rails platform since 2010.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s