1. Home
  2. Linux
  3. Hard drive usage linux qdirstat

How To Analyze Hard Drive Usage On Linux With Qdirstat

With how large data can be nowadays, hard drives can fill up quickly. For this reason, it’s a good idea to install a tool that lets you analyze hard drive usage to help you keep track of large files, and delete them if need be.

SPOILER ALERT: Scroll down and watch the video tutorial at the end of this article.

Install Qdirstat

On Linux, one of the best hard drive analysis tools users can install is Qdirstat. It’s Qt-based, open source and does an outstanding job of quickly determining the location of large files and folders on your Linux PC.

Ubuntu

sudo apt install qdirstat

Debian

sudo apt-get install qdirstat

Arch Linux

Fans of Arch can install Qdirstat through the AUR if they want to use it, as the developers don’t officially support it.

To install Qdirstat on Arch Linux, open up a terminal window and use the Pacman tool to install both Git and Base-devel. These two packages are critical, and building the software is impossible without them.

sudo pacman -S git base-devel

Now that both Git and Base-devel are on your Linux PC, it’s time to download the latest version of the Qdirstat AUR build files. Grabbing the build files for Qdirstat is done with the git clone command.

git clone https://aur.archlinux.org/qdirstat.git

CD into the code folder.

cd qdirstat

In the code folder, run the makepkg command. Running makepkg here will generate an installable Arch package for Qdirstat. Keep in mind that when you run this command, the build may fail if it can’t install all of the Qdirstat dependencies.

makepkg -si

Fedora

sudo dnf install qdirstat -y

OpenSUSE

sudo zypper install qdirstat

Generic Linux

The source code is available for Qdirstat if you’re on a Linux distribution that doesn’t have an easy way to install it. Launch a terminal window and follow along to learn how to compile Qdirstat.

Before compiling the code, it’s essential to install all of the dependencies that the Qdirstat code needs. Search for these programs using your package manager and install them.

  • C++ compiler
  • Git
  • Qt 5 runtime environment
  • Qt 5 header files
  • libz (compression lib) runtime and header file

The Qdirstat building process starts by cloning the code with the git clone command.

git clone https://github.com/shundhammer/qdirstat.git

Move your terminal into the Qdirstat code folder with CD.

cd qdirstat

Invoke the qmake build command to start the compilation process.

qmake

After Qmake finishes, run the make command. Make will finish off the compilation of Qdirstat.

make

Install Qdirstat to your Linux PC with:

sudo make install

Scan Directories

To start scanning for files and folders, open Qdirstat. As soon as the program opens up, you’ll see a selection window. The file browser lists all of the directories it can access on the system. Look through the file browser window and select the area you’d like to scan. For most users, the ideal folder to choose is “home.”

Note: it’s possible to scan other hard drives, aside from the one where your Linux OS is set up. To do this, click the left-hand sidebar in the Qdirstat file browser, locate your desired hard drive and access it. Keep in mind that Qdirstat will not work with drives that are not mounted.

Now that Qdirstat has a scan location to work with, you’ll notice the left side of the program starts to populate a list of folders. These folders are scan results, and the program organizes them based on how large they are in size. Click on the arrow icons to sort through folders, and look at files. Like the folders, Qdirstat sorts data from biggest to smallest.

Navigating Data

When the Qdirstat tool scans a folder on your Linux PC, it’ll populate a directory tree on the left side of the window. This folder structure is very straightforward and easy to navigate. On the right side of the screen, you’ll see a graph with various squares in different colors.

The data graph allows users to see a visual representation of the data in the directory they scanned. To view a file through the Qdir visual chart, click on any square. Selecting a square will instantly show the exact location of the data in the Treemap on the left. Alternatively, you can right-click on a data square and click “copy URL” to get its location on your computer.

Delete Large Files

If you’re looking to delete a file or folder in Qdirstat, view the directory structure on the left (or the data graph on the right), right-click on a search result and click the “delete” button. Selecting “delete” will remove the file from your Linux PC instantly, so be careful! Don’t use the delete feature unless you’re sure!

Aside from deleting files, the Qdirstat also has a “move to trash feature.” To use it, look to the folder structure or data graph, find a search result and right-click on it. In the right-click menu, select “move to trash.”

6 Comments

  1. The treemap is actually that graph on the right side, not on the left; that would be the directory tree as in any file browser since the mid-80s.

    Not only does the size of each tile of the treemap correspond to the size of a file, its color also shows the file type (if known; otherwise it’s just grey).

    And there are many more operations that you can do with a file, not only delete or move to trash; you can also compress it, for example. You can also create your own cleanup operations – say, recompress JPG images, if you like.

    • Ah yes, thanks for the feedback. I miswrote “Treemap” and have corrected it. Sometimes these typos happen, so thank you for catching it.

      In any case, I really like Qdirstat, and we’ll be digging more into it’s advanced functions in future articles.

  2. Actually, the treemap is not that thing on the left side; that is the traditional tree view that everybody should know from file browsers (going back to PC Tools in the mid-80s). The treemap is the graph on the other side.

    Reading the documentation might have helped… 😉

    Kind regards
    Stefan Hundhammer
    QDirStat Author

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.