Display disk space
This page was last updated on July 18, 2009.
Disk Free Space
- Use this command to check how big your drives are and how much space is used and free.
- Example result:
df -h
Filesystem Size Used Avail Use% Mounted on /dev/sda3 292G 130G 147G 47% / varrun 1013M 180K 1013M 1% /var/run varlock 1013M 0 1013M 0% /var/lock udev 1013M 44K 1013M 1% /dev devshm 1013M 0 1013M 0% /dev/shm lrm 1013M 20M 994M 2% /lib/modules/2.6.24-23-generic/volatile /dev/sda1 950M 110M 793M 13% /boot
Note: The -h argument makes it human readable.
Directory Size
To check the size of a specific directory, substitute the path to the directory for * in any of the commands below.
- This command displays the size in MB of the folders and/or files in the current directory:
- Example result:
du -sm * | sort -n
1 draft 1 inbox 1 queue 1 sent 1 trash 179 Saved Mail
Note: Any folder or file that is 1MB or smaller will be displayed as 1.
- This command displays the size in KB of the folders and/or files in the current directory:
- Example result:
du -sc * | sort -n
12 draft 12 inbox 12 queue 12 sent 192 trash 182508 Saved Mail 182748 total
- This command displays the size in KB and MB of the folders and/or files in the current directory:
- Example result:
du -sh * | sort -n
12K draft 12K inbox 12K queue 12K sent 179M Saved Mail 192K trash
- This command displays the size in KB and MB of all the folders and or files in the current directory and all its subdirectories:
du -h * | sort -n
Obligatory Happy Ending
And they all lived happily ever after. The end.
