Hardware

A Few Ways To Visualize Disk Usage In Linux

I woke up this morning, took care of things like showering and eating, and then meandered to my computer. Swishing the mouse back and forth brought the screen to life, where I was greeted by a message that my computer was out of space.

It turns out that a backup cron job seems to have gone haywire and I had nested backups on my internal disk drive that occupied a great deal of space. However, I had only a hunch and couldn’t see where the problem was.

The problem was, as it turned out, a folder in /home/kgiii – and it was helpfully named as a backup should – meaning the errant directory was /home/kgiii/kgiii.

Of course I’m not going to notice that! The directory name doesn’t look out of place! It looks like it belongs there, it looked perfectly normal, so it didn’t leap off the screen to tell me something was amiss.

Really, I’m definitely not going to notice it while catching up on everything I check daily and while still on my first cup of coffee! The directory was my username in a directory named my username. It might just as well have been microscopic.

Either way, I didn’t worry too much. I knew that I should have plenty of space and that I could probably figure it out pretty easily. After all, it’s easy to visualize disk usage in Linux. This article show you a few ways to visualize your disk space. It should also be a pretty short article.

Visualize Disk Usage:

#1 Baobab:

Baobab is the first of the three, and the most unique of the three. It’s not that it’s particularly unique, it’s that the other two are really quite similar. It’s typically a part of the GNOME desktop, but can easily be installed most any system. If you’re using a distro with apt, it’s installed with:

sudo apt install baobab

You can open it up, drill down, and graphically see how your disk is being used. You can see which files and folders are taking up the most space. It looks like this:

My Documents directory is nice and empty. I should have taken screenshots sooner.

It’s really self-explanatory after you’ve installed and opened it. Baobab is named after the tree, and appropriately shows the drives and directories in tree format. Imagine that!

#2 K4DirStat

K4DirStat is typically used with KDE, but can be installed on most any desktop. It’s another handy GUI way to visualize disk usage. If you’re a recent Windows user, then it may remind you of WinDirStat as the two are visually similar. It’s easy enough to install. Again, if you use apt:

sudo apt install k4dirstat

K4DirStat is pretty self-explanatory. Open it, select where you want to start investigating, and wait. Once open and/or you’ve drilled down, it looks like this:

This one is pretty intuitive and fun to play with while viewing disk usage.

This one has been around for quite a while. You may already be familiar with it. These applications are all a little slow when opening, as they have a lot of data to load and calculate. So, you’ll need to be patient.

#3 QDirStat:

QDirStat is pretty much exactly the same thing as the above. It’s based on K4DirStat, but built with and for the Qt library. So, you’ll want to consider it as an option if you’re using something like Lubuntu which is now using LXQt. But, most modern Linux distros support Qt out of the box and you can install it with:

sudo apt install qdirstat

Visually, it looks much like K4DirStat. It’s a simple block view that shows you the file sizes in comparison with the files around it. It will also helpfully color-code files. It looks like this:

As you can see, it looks a lot like the previous option. Not a whole lot going on there.

It’s pretty similar to a few other applications that do much the same thing. The main benefit for this option is that it is Qt and that’s fairly universal these days.

Also, it looks pretty cool if you’re looking at the entire drive with it. This picture isn’t really of any value, it’s just because it looks neat. Call it a bonus picture!

This picture serves no purpose, but the colors are pretty!

Closure:

If you’re curious, I used the QDirStat because that was what I had installed and ready to go. It didn’t take very long to figure out where the problem was. Once I knew where it was, I cracked open the terminal and removed the offending directory and the contents within. I then removed the offending cron job, with a note to myself to fix it later today. This resolved my problem quickly.

Had I tried to find it visually through the file manager, I’m quite certain that it’d have taken quite a bit longer. The name of the directory didn’t make it seem out of place. In fact, I’ve had a ‘kgiii’ directory right there in my home directory in the past. I stopped doing that when it got confusing, so now it’s a ‘tmp’ folder, though I digress. The point is, I’d have taken quite a while to figure this out had I not had the tools to hand and known how to use them.

Finally, I have a ton of notes from which to write articles, but sometimes real life gives me an idea for a different article, such as this one. If you have an idea for an article, you can go ahead and write it. You can also unblock ads, donate, sign up for the newsletter below, leave a comment, and more! Thanks for reading!

KGIII

Retired mathematician, residing in the mountains of Maine. I may be old and wise, but I am not infallible. Please point out any errors. And, as always, thanks again for reading.

View Comments

  • I smashed five stars on this one (I am your PFSS (Phantom Five Star Smasher), but you've asked for feedback and here it is. Not on the subject matter, but site presentation.

    You could do with tricking your screenshots so that mouse over brings up the Fickle Finger of Fate to expand the picture to make it more visible. Other than that, I am left with hitting the Ctrl ++ option to enjoy "...but the colors are pretty".

    Cheers and keep up the good work.

    wizardfromoz

    • I am working on it as I type this. There's surely a plugin (out of the 55,000+ plugins) that does this without adding a bunch of bloat, slowing down the page load times, and is simple enough to only do this one task.

      If not, there are many 'gallery' suite types of plugins and one of 'em will surely do the trick for images that should be able to be expanded to full size.

      Thanks for the usability feedback. I'll see what I can do.

  • So you didn't even bother to read the documentation?

    You would have found out that QDirStat is the newer version based on the same code where K4DirStat comes from, just with a bunch of improvements.

    And you wouldn't even had needed a shell; both programs can delete files and directories directly.

    • I'm a bit baffled that you think I don't know where QDirStat came from. It clearly says that on the page I linked to. Not only that, I also mention that it did in the text of the article that you clearly didn't read.

      And, I do everything like that in the terminal. I trust my use of the shell explicitly. Just because you need some GUI to do it for you doesn't mean everyone wants to do it that way. That's the great thing about Linux! I can delete the files any way I want.

      Anyhow, thanks for trying to contribute. Maybe you can do better next time?

      In fact, if you want to do something positive, you can figure out why the first image is so damned big even when I keep telling the system to make it the same size as the others. Now that'd be a good use of your time and my time.

  • Update: Woohoo! I think I fixed the first image. It was giant, but now it's the right size.

    Well, it's the right size on Chrome. I haven't checked other browsers.

Recent Posts

Enable/Disable Your Network Interface

Today we'll cover one way to enable or disable your network interface in the Linux…

5 months ago

Check Your NIC Speed In The Terminal

Today's exercise is a nice and simple exercise where we check your NIC speed in…

5 months ago

Easily Monitor Your Wireless Connection

Have you ever wanted to easily monitor your wireless connection? Well, now you can learn…

6 months ago

Count The Files In A Directory

I think I've covered this before with the ls command but this time we'll count…

6 months ago

Get System Information With The ‘uname’ Command In Linux

Today we'll be learning about a basic Linux command that's known as 'uname' and it…

6 months ago

hardinfo Has Been Rebooted As hardinfo2

If you've used hardinfo in the past, it may interest you to know that hardinfo…

6 months ago