This is a letter to future me for the next time I need to look up the disk usage in the terminal. If you find this useful, great, if you think this is lacking and unhelpful, that’s fine too. I don’t always remember how I used various commands in the terminal when there are weeks or months between and it isn’t immediately in my Bash history.
Why?
There are some systems that I interact with, purely in the terminal and the way that I have to interact with them is purely in the terminal. There are no graphical tools to do the job where I can click and get what I want so it is good that I know specifically HOW to do a task in the world of Linux or Unix or whatever system that it is.
What I needed to do was find the location on the file system in the partition that was eating up a many, many gigabytes of storage and wipe out as much as necessary to accomplish another task.
Solution
The command that saved my bacon: du
This command simply tells you the “Disk Usage” at whatever point(s) you specify. Simply output, how much disk usage is at a specified directory. I added -sh to exclude all subdirectories and output in a “human readable” format.
sudo du -sh
This will give you the simple output of the current disk usage.
1.1T .
This isn’t necessarily all that useful. It was my intent to determine what directory was eating up all my disk space. That can be done, simply, by adding a different option. Just as an example, I am using the root directory of my computer.
sudo du -h --max-depth=1
22M ./etc
339G ./.snapshots
29G ./var
15G ./usr
0 ./srv
75M ./root
1.6G ./opt
1.1T ./home
105M ./boot
112K ./dev
0 ./proc
0 ./sys
5.4M ./run
0 ./mnt
4.2M ./tmp
9.4G ./snap
17M ./.Trash-0
1.4T .
Notice the last line is the summation of the directories. I can see that there is just way, way too much in my home directory.
It might be fun to investigate what is taking up so much space in /var so I will go into that directory and run the command again.
1.3G ./log
28G ./lib
300M ./cache
3.2M ./tmp
244M ./adm
0 ./crash
0 ./opt
7.5M ./spool
0 ./games
9.9M ./snap
29G .
Here I can see that the /var/log is taking up quite a bit of space and I could investigate further into that directory. Alternatively, you can increase that “max depth” number to dig into more than one level of folders but it very quickly gets a little out of control. I find that a max-depth of 1 tends to work best for me.
Final Thoughts
Now, if you are stuck in the terminal and can’t use the kool Plasma tools to visualize your directories, you can play the super sleuth of the terminal, digging around, looking for what is eating up your bytes.
Future self, you are welcome.

Leave a Reply