To know about used space of each partition, we usually use df command. See example below:
[bash]df -h[/bash]
And we get a result like this:
1 2 3 4 5 6 7 8 9 10 |
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.
[bash]du -h[/bash]
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:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
carlos@archpanzer:~$ du -h --max-depth=1 . | sort -h 4.0K ./Desktop 4.0K ./.freerdp 4.0K ./.gnome2 4.0K ./Music 4.0K ./Templates 4.0K ./.themes 4.0K ./Videos 8.0K ./.netbeans 8.0K ./.putty 8.0K ./.vim 12K ./.dbus 16K ./.adobe |
:)