How can I get the current disk usage (in %) of my hard drive from the command line?
Asked
Active
Viewed 3e+01k times
193
-
Now I wonder if there's some commandline equivalent of `kdirstat` or `baobab`. – Ehtesh Choudhury Jun 06 '13 at 23:15
-
http://superuser.com/questions/9847/linux-utility-for-finding-the-largest-files-directories – belacqua Aug 08 '14 at 21:41
2 Answers
201
ncdu
Works well from the command line. It's ncurses-based and interactive.
You can install it with sudo apt-get install ncdu.
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.
N0rbert
- 97,162
- 34
- 239
- 423
Ehtesh Choudhury
- 5,431
- 3
- 19
- 15
-
3
-
1I 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
-
3`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 04 '18 at 18:52
-
-
The Top ten item above is very helpful, however, it omits hidden directories. Is there an easy way to include them? – dvhirst Jan 05 '21 at 05:57
181
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.
htorque
- 63,950
- 40
- 194
- 219
-
51`df -m` will show things in megabytes, `df -h` will show you in the largest possible unit. – Oli Jan 11 '11 at 15:48
