To know about used space of each partition, we usually use df command. See example below:
And we get a result like this:
Filesystem Size Used Avail Use% Mounted on
/dev/sda8 68G 45G 20G 70% /
none 4.0K 0 4.0K 0% /sys/fs/cgroup
udev 7.8G 4.0K 7.8G 1% /dev
tmpfs 1.6G 1.3M 1.6G 1% /run
none 5.0M 0 5.0M 0% /run/lock
none 7.8G 32M 7.8G 1% /run/shm
none 100M 24K 100M 1% /run/user
/dev/sda9 60G 15G 43G 25% /home
/dev/sda1 496M 51M 446M 11% /boot/efi
In some cases, we’ll add sudo before command to list partitions mounted by others users.
When we need to know about the size of each folder, linux provide us other special program called du.
[bash] du /home/user/some-dir/[/bash]
Such as other programs, du has a lot of arguments and its can combined with other programs like sort.
Now, to get some folders sorted by size, we can send ‘du -h’ output to sort program:
[bash]du -h | sort -h[/bash]
All folders and sub folders will be printed sorted by their sizes. If you limit by only first depth, you can use –max-depth arg.
[bash]du -h –max-depth=1 | sort -h[/bash]
You’ll get a output like:
carlos@archpanzer:~$ du -h --max-depth=1 . | sort -h