123

How can I get the current disk usage (in %) of my hard drive from the command line?

128

By using the df command.

Here's an example output:

$ df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sda1            303537496  27537816 260580948  10% /
none                    950788       252    950536   1% /dev
none                    959516       232    959284   1% /dev/shm
none                    959516       388    959128   1% /var/run
none                    959516         0    959516   0% /var/lock

Also take a look at its manpage.

  • 33
    df -m will show things in megabytes, df -h will show you in the largest possible unit. – Oli Jan 11 '11 at 15:48
99

ncdu

Works well from the command line. It's ncurses-based and interactive.

enter image description here

Alternatives

  • Top ten: du -shx * | sort -rh | head -10
  • If you want more fine grained disk usage, you should take a look at the answers here.
  • 2
    Install this via sudo apt install ncdu – Pedi T. May 17 '17 at 4:43
  • 1
    I liked the alternatives. You have to be in the directory you are looking for the large files. But I found it easy to spot the culprit this way without having to install anything. – G Trawo Sep 18 '18 at 14:49
  • du -shx * | sort -rh | head -10 is a lifesaver! Especially great if you are on a small test server, you have run out of space, and do not already have a fancy utility installed to fix your problems. – Michael Plautz Oct 4 '18 at 18:52

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.