After running your Linux for a period of time, it creates caches, unused temporary files and other date. There files may be useless, so you can safely remove them to free up disk spaces.
If your Ubuntu file system is getting full, here are 10 ways that may help to free up more disk space.
1. Clear Trash / Temporary Files & Enable Auto Deletion:
Emptying the Recycle Bin is always the first step to free up more space. In Ubuntu, you may do this easily via right-click menu option of the trash in Desktop, Left Dock, or File Manager.
By default, Ubuntu keeps a record of files that you have used. As well, it generates temporary files like Mircosoft Windows. By going to “Settings -> Privacy -> File History & Trash“, you’ll see the buttons to clear these files. Also, it provides options to automatically remove trash content & temporary files in given time interval.
2. Remove Unused Applications:
Unused applications, especially SNAP and Flatpak apps, may take up a few GB spaces. Search for and open “Ubuntu Software” from the activities overview. There you’ll see the “Installed” tab with a list of apps along with ‘Remove’ button, including Snap and Run-times.
3. Remove Unused Flatpak Apps & Run-time libraries:
Ubuntu Software by default does not handle the Flatpak apps. If you have some installed, press Ctrl+Alt+T on keyboard to open terminal. Then run following commands one by one to clean up.
a.) List all installed Flatpak apps using command:
flatpak list
I'd recommend to Maximize the terminal app before running the command. Since "App ID" is usually very long, it may sometimes not fully displayed on small terminal window.
b.) Next, you may remove a flatpak app as well as its data via command:
flatpak uninstall --delete-data Applications-ID
c.) A single unused run-time library may take up a few hundred of MB space. So, you may try to clear them via command:
flatpak uninstall --unused
4. Remove Snap and Flatpak apps cache:
Removing Flatpak app without --delete-data
or Snap without --purge
flag may has the app data left in user directory.
For Snap apps, simply open file manager and you’ll see the “Snap” folder in user home. Each snap app has a sub-folder in that directory. Delete the sub-folders if the apps are already removed.
And, Flatpak stores personal app data in “.var/app/“. You may clear app caches either via command flatpak uninstall --delete-data
, or manually remove sub-folders from that directory. NOTE, you need to press Ctrl+H in file manager to show hidden folders.
5. Remove browser caches & old Kernels:
Web browsers remember your browsing history and store the data in the disk. As well, Ubuntu keeps updating new Linux Kernel with security fixes, so it will be a few old Kernels left in system.
To clean them up, you don’t have to open each browser or use any unacquainted commands. “Ubuntu Cleaner” is a nifty tool to do the trick for you:
And all Ubuntu releases may install the tool via its official PPA, by opening terminal and running commands below one by one:
sudo add-apt-repository ppa:gerardpuig/ppa
sudo apt update
sudo apt install ubuntu-cleaner
6. Clear up & Limit system journal log:
Ubuntu has a logging system called the journal. It stores logs in “/var/log/journal” directory for debugging purpose. Personal computers may not use these file at all. So, you may remove them and enable auto deletion.
a.) Firstly, press Ctrl+Alt+T on keyboard to open terminal. When it opens, run command to check the log size:
journalctl --disk-usage
After a long time usage, it may even take a few GB disk space.
merilyn@focal:~$ journalctl --disk-usage Archived and active journals take up 3.5G in the file system.
b.) If you decide to clean up system journal, use the command to archive the current log first:
sudo journalctl --rotate
c.) Finally, either set to automatically delete logs (for example in 30 days) via command:
sudo journalctl --vacuum-time=30days
or automatically clear log when it reached the certain size (100 MB for instance):
sudo journalctl --vacuum-size=100M
7. Remove user data for native DEB apps:
Native apps in deb format usually create hidden folders in user’s home directory to store personal user data, caches, configurations, etc.
These folders are left there even after you removed them. Open file manager and press Ctrl+H and you’ll see a lot of the “.xxx” folders. If you have removed these apps, it’s safe to remove the relative folders. And, some may create sub-folders under “.cache“, “.config” and/or “.local” directory.
8. Remove unused Themes, Icons, etc:
If you’ve tried out some GTK themes, icon sets or fonts and do not use them anymore. Remove them by going to .themes, /usr/share/themes, /usr/local/share/themes, or .local/share/themes. And, remove unused icons from .icons, /usr/share/icons, /usr/local/share/icons, or .local/share/icons.
9. Clear unused sub-folders under /opt/:
Some apps install data into /opt directory for optional add-on software packages. Usually, removing an app will also remove its sub-folder (if any) in /opt directory. However, some not well packaged apps may not do this properly.
Open terminal via Ctrl+Alt+T, and run command to list sub-folders in /opt:
ls /opt
merilyn@focal:~$ ls /opt/ Caprine FreeFileSync microsoft utorrent-server-alpha-v3_3 extras.ubuntu.com google soundux vivaldi firefox lib sublime_text wine-devel
If you’re SURE an app has been removed but its data folder left here. Remove it via command (FreeFileSync in my case):
sudo rm -R /opt/FreeFileSync
NOTE: run this command carefully! If your app is still present, it may not function after doing the command.
10. Clear apt cache, bash history and other App cache:
Install native applications (non-Snap / non-Flatpak) leave caches in your system. And, Ubuntu remembers the history of commands you run previously. Also, other useful apps (e.g., video players and email clients) may leave caches that are safely to remove.
For all of them, you may use the “BleachBit” tool to clean up.
And, the app can be installed either from “Ubuntu Software” or by running command in terminal:
sudo apt install bleachbit
In addition:
If you still have no enough free space in Ubuntu. Search for and open “Disk Usage Analyzer” from activities overview. Then click on your system disk or home folder, it will tell your which files are eating up the spaces.
That’s all. Enjoy!
Recent Comments