$ 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
Author: Abhilash
Hi, Iโm Abhilash! A seasoned web developer with 15 years of experience specializing in Ruby and Ruby on Rails. Since 2010, Iโve built scalable, robust web applications and worked with frameworks like Angular, Sinatra, Laravel, Node.js, Vue and React.
Passionate about clean, maintainable code and continuous learning, I share insights, tutorials, and experiences here. Letโs explore the ever-evolving world of web development together!
View all posts by Abhilash