How to Detect and Clean Up Hard Disk Storage with QDirStat in Linux

Qdirstat Reclaim Storage Featured

QDirStat is the evolution of the older, tried and tested KDirStat tool, by the same author, Stefan Hundhammer. Both programs serve the same purpose: presenting statistics of how our computer’s storage is used in a human-friendly manner.

The program doesn’t show its findings with raw numbers and percentages but in a hierarchical tree structure and a graphical map. This makes it easy to pinpoint the largest space hogs: to find and delete unneeded files and reclaim the space they take up.

Self-conscious, QDirStat knows we will use it for reclaiming storage space and includes some functions that help with that. The app doesn’t only display statistics about files – it also allows you to take action on them. You can delete them through the app, clean remnants from GIT syncs or make runs, and remove trash files. And you can customize all those or add your own cleanup scenarios.

Install QDirStat

You can probably find QDirStat in the software center of your distribution. Search for it using its name from the primary graphic software-management tool of your distribution and install through it.

Qdirstat Reclaim Storage Installation

If you prefer the terminal, on Debian and Ubuntu compatible distributions you can bring it on-board with:

Unlike its older sibling, KDirStat, QDirStat doesn’t demand KDE (or Gnome or some other desktop environment) libraries, apart from QT and Perl, so it will be a relatively quick and painless installation.

Select the path to analyze

When ran, QDirStat jumps straight into action by asking what source path it should investigate. You can select any path that’s accessible through your file manager, either local or remote (for example, SMB shares on a local Windows network). If it’s mounted and accessible, QDirStat can use it.

Qdirstat Reclaim Storage Path To Analyze

After selecting a path, click “Open” to select it and move to QDirStat’s main window.

Tree view and visual map

After analyzing the selected path’s contents for a short while, QDirStat will present its findings in two different ways in its main window.

The first one is a “tree view” not unlike the one you might be familiar with from typical file managers. The difference is that QDirStat arranges it by default based on the size of each entry, with the largest space hogs on top.

With a single glance, you can check how much a folder takes up in usage percentage, its actual size in (K/M/T) Bytes, etc.

Like a file manager’s tree view, you can expand any folder to see its contents by clicking on the small arrow on its left.

Qdirstat Reclaim Storage Different Views

On the bottom of the window you can see the second, graphical view of everything in the path.

Each rectangle represents a different file, and the larger the rectangle, the more space the file it represents eats from your storage.

Trash and delete files

When you locate a file or folder you want to eliminate, right-click on it and choose Move to Trash or select it and then press Delete on your keyboard.

The file/folder will remain in the OS’s trash folder until it’s purged or other files require the space it takes up.

Qdirstat Reclaim Storage Trash Delete

For permanent deletion, choose the “Delete (no way to undelete!)” option or press Ctrl + Delete on your keyboard with a file or folder selected.

As clearly stated, double-checking what you delete with this option is useless because there’s no undo.

Compression and cleanup actions

When selecting folders instead of files, QDirStat offers more options for reclaiming lost storage space.

Right-click on a folder, and QDirStat will allow you to compress its contents (with tar it creates bz2 files) to reduce the space they take up.

Qdirstat Reclaim Storage Compress Folder

You can also clear any remnants of make or GIT syncs by choosing those options (“make clean” and “git clean”) from the right-click menu.

Avoid “Clear Directory Contents,” since it will wipe out everything in a folder (unless that’s what you require).

Finally, “Delete Junk Files” eliminates the files it locates in the selected path that it recognizes as junk. You can specify what those are yourself in QDirStat’s Settings.

Cleanup customization

Choose “Settings > Configure QDirStat” to do precisely that, configure QDirStat. The program groups its customization options in four tabs.

Qdirstat Reclaim Storage Customization

Cleanup Actions allows you to checkthe existing functions the program can run on selected files and folders. Although its name suggests they only have to do with the removal of data, here you’ll also find the “Open File Manager Here” and “Open Terminal Here” options. You can reorganize the actions and add new ones if you wish.

MIME Categories is where you can define different groups of files based on patterns identified in their filename. You could, for example, include temporary files in the “Junk” MIME Category by adding a “*.tmp” entry in the “Patterns (Case Insensitive)” field.

Exclude Rules makes up a list of files and folders the program won’t touch. It would probably be best to add here any important folders and files you wouldn’t want to be affected by the program’s operation.

General contains some basic options regarding the app’s operation and aesthetics – feel free to skip it.

Keep it clean

QDirStat is very useful in uncovering the large-but-useless files that eat up your storage space, but as we saw, it’s even more helpful if you customize the existing, or set up your own, cleanup actions.

This way, you’ll know what each of those does and how it might affect your files, and create cleanup scenarios, where sending redundant data to oblivion will be a matter of two clicks.

One comment

  1. First step on doing anything to your disk, back up your data to another drive! And don’t forget those web browser bookmarks.

Leave a Comment

Yeah! You've decided to leave a comment. That's fantastic! Check out our comment policy here. Let's have a personal and meaningful conversation.