6 Tips to Free up More Disk Space in Linux

Need to free up disk space in your Linux? Here are a few tips that may help!

After running for a long period of time, every system produces junk files and other useless data. Users are looking for how to get rid of them since it takes more and more disk spaces.

There are a few good system cleaning tools for Linux, but they will never clean all the things. So I’m writing this tutorial with a few more tips.

Tell How Much Free Disk Space in Linux:

You can open a disk usage analyzing tool to check how much free space available. But running the command below in a terminal or console will work on all Linux, either with or without a desktop environment:

df -h

While Linux system are mostly mounted on “/“, check the size in that output line to see the free space.

1. System Cleaning Tools:

Now if you found that there are not so much free spaces, first things you should try is using a system cleaner. And BleachBit is the most popular one.

BleachBit cleans the system package cache, bash history, web browser cache, desktop usage history, clipboard, trash, temporary files, chat / email caches, and so forth.

It is available in most Linux repositories, including Ubuntu, Fedora, Debian, CentOS, and more. Simply install it from system app center or via package manager, and then clean common junk files.

2. Remove old Kernels:

Some Linux, e.g., Ubuntu, keeps publishing Kernel updates for either security fixes or new hardware support. Although apt autoremove command remove old Kernels, it still keeps the last few ones.

In case of running into Kernel issue, you can fall back to old Kernel by booting from Grub boot menu. If you intend to remove these old Kernels to get more spaces, try Ubuntu Cleaner.

Or run this command in Fedora / CentOS Linux:

sudo dnf remove $(dnf repoquery --installonly --latest-limit=-2 -q)

3. Limit Systemd Journal Logs:

See the journald clean option in BleachBit? As you may know, most Linux now uses systemd system and service manager instead of init.

Systemd has its own logging system called the journal. It stores log files in /var/log/journal which can take a few GB disk spaces.

If you don’t use it for debugging, you can either clean it every time via BleachBit, or set size limit to the log.

Firstly, mark the currently active Journal files as archived by running command in terminal:

sudo journalctl --rotate

Next, choose one of the actions below as you prefer:

  • Automatically delete journal logs older than X days (2 days for example):
    sudo journalctl --vacuum-time=2days
  • Limit log files to given size (50MB for instance):
    sudo journalctl --vacuum-size=50M
  • Set the maximum file number of log files:
    sudo journalctl --vacuum-files=5

4. Clear Un-used App Data:

Many apps create personal app data & config folders in user’s home directory. Even after uninstalled, these folders are still there to take up disk space.

Open file manager, and press Ctrl+H on keyboard. You’ll see all the hidden folders with “.” at the beginning of their names.

Some apps are already removed, but the data folders (.audacity, .audacity-date, .atom, etc, in my case) and those under .config are left there. You can safely delete them, if the apps are already remove, to free up even more disk space.

5. Remove un-used Flatpak Apps & Run-time Libraries:

More and more apps produce Linux binary via Flatpak package, and you may have installed some on your Linux.

If you removed Flatpak app without --delete-data flag, check the .var/app folder. There may be unused app data left.

As well, Flatpak will NOT remove unused run-time libraries (fixed in Linux Mint 20.2). So you can run the command below to clean it up regularly:

flatpak uninstall --unused

And to remove unused flatpak apps, see HERE for details.

6. Remove unused Snap App Data:

Snap is another universal package format for Linux powered by Canonical Ltd., the company behind Ubuntu.

For Ubuntu users using Ubuntu Software to install / remove apps, you may have many snap packages installed. And you’ll see a snap folder in user’s home directory.

There stores the personal app data for Snap packages. If removing snap apps without --purge flag, un-used app data will be left in that folder. And you can safely remove these un-used sub-folders to free up more spaces.

Final Words:

There may be more tips to free up disk space in Linux that I do not know. Feel free to leave a comment here if you got one!

Exit mobile version