How to Clean Up Flatpak Apps and Reclaim Disk Space
Optimizing Disk Space on Linux with Flatpak Cleanup Commands
Introduction
Flatpak, a popular package management system, provides a sandboxed environment for running applications. However, this sandboxed nature can result in the accumulation of significant disk space over time. In this guide, we will walk you through the process of cleaning up Flatpak apps to free up precious disk space on your Linux system.
Where Flatpak Packages are Installed
When you install a Flatpak package, it is stored in two primary locations on your system:
- System Installation Directory:
/var/lib/flatpak
This directory contains all the files, metadata, application files, and runtime files shared among all Flatpak apps.
2. User Installation Directory: ~/.local/share/flatpak
Flatpak data specific to each user, including installed applications, is stored in this directory.
How to Find Out the Size of Flatpak Apps
Before proceeding with cleanup, it’s helpful to identify the disk space occupied by Flatpak apps. Here are some commands you can use:
- Check the size of
/var/lib/flatpak
du -h /var/lib/flatpak
2. Use Disk Usage Analyzer
Alternatively, you can visually inspect the size of Flatpak data by using a disk usage analyzer tool.
3. List installed Flatpak packages
- by name and size
flatpak --columns=name,size list
- by app, name and size
flatpak --columns=app,name,size,installation list
Output is like this:
Application ID Name Installed size Installation\
io.podman_desktop.PodmanDesktop Podman Desktop 306.5 MB system\
org.fedoraproject.Platform Fedora Platform 1.8 GB system\
org.fedoraproject.Platform Fedora Platform 1.9 GB system\
org.fedoraproject.Platform Fedora Platform 2.0 GB system\
org.fedoraproject.Platform Fedora Platform 2.0 GB system\
org.freedesktop.Platform Freedesktop Platform 576.2 MB system\
org.freedesktop.Platform.GL.default Mesa 385.2 MB system\
org.freedesktop.Platform.GL.default Mesa (Extra) 385.2 MB system\
org.freedesktop.Platform.VAAPI.Intel Intel 53.3 MB system\
org.freedesktop.Platform.openh264 openh264 790.0 kB system\
org.geany.Geany Geany
- by name and size per user
flatpak --columns=name,size --user list
The Best Resources For Ansible
Certifications
- Coursera Pro - Unlimited access to 7,000+ world-class courses, hands-on projects, and job-ready certificate programs—all included in your subscription
Video Course
Printed Book
-
Ansible For VMware by Examples
-
Ansible for Kubernetes by Example
-
Hands-on Ansible Automation
-
Red Hat Ansible Automation Platform
eBooks
- Ansible by Examples: 200+ Automation Examples For Linux and Windows System Administrator and DevOps
- Ansible Cookbook: A Comprehensive Guide to Unleashing the Power of Ansible via Best Practices, Troubleshooting, and Linting Rules with Luca Berton
- Terraform By Example: A Practical Approach for Beginners to Learn Cloud Infrastructure with Terraform
- Ansible For Windows By Examples: 50+ Automation Examples For Windows System Administrator And DevOps
- Ansible For Linux by Examples: 100+ Automation Examples For Linux System Administrator and DevOps
- Ansible Linux Filesystem By Examples: 40+ Automation Examples on Linux File and Directory Operation for Modern IT Infrastructure
- Ansible For Security by Examples: 100+ Automation Examples to Automate Security and Verify Compliance for IT Modern Infrastructure
- Ansible Tips and Tricks: 10+ Ansible Examples to Save Time and Automate More Tasks
- Ansible Linux Users & Groups By Examples: 20+ Automation Examples on Linux Users and Groups Operation for Modern IT Infrastructure
- Ansible For PostgreSQL by Examples: 10+ Examples To Automate Your PostgreSQL database
- Ansible For Amazon Web Services AWS By Examples: 10+ Examples To Automate Your AWS Modern Infrastructure
- Ansible Automation Platform By Example: A step-by-step guide for the most common user scenarios
Commands to Clean Up Flatpak Apps
Now, let’s proceed with cleaning up Flatpak apps to reclaim disk space:
- Uninstall Unused Flatpak Packages:
flatpak uninstall --unused
This command safely removes Flatpak packages that are no longer in use.
Output is like this:
ID Branch Op\
1. [-] org.fedoraproject.Platform f31 r\
2. [-] org.fedoraproject.Platform f33 r\
3. [-] org.fedoraproject.Platform f34 r
Uninstall complete.
- Uninstall a Specific Flatpak Package:
flatpak uninstall <application ID>
Replace <application ID>
with the name of the Flatpak app you want to uninstall.
- Remove All Flatpak Packages (Use with Caution):
flatpak uninstall --all
Exercise caution with this command, as it removes all Flatpak packages from your system. Ensure you understand the potential consequences.
Output is like this:
ID Branch Op\
1. [-] io.podman_desktop.PodmanDesktop stable r\
2. [-] org.freedesktop.Platform 22.08 r\
3. [-] org.freedesktop.Platform.Locale 22.08 r\
4. [-] org.freedesktop.Platform.openh264 2.2.0 r\
5. [-] org.freedesktop.Platform.GL.default 22.08 r\
6. [-] org.freedesktop.Platform.GL.default 22.08-extra r\
7. [-] org.freedesktop.Platform.VAAPI.Intel 22.08 r\
8. [-] org.geany.Geany stable r\
9. [-] org.fedoraproject.Platform f35 r
Uninstall complete.
4. Remove Flatpak Cache Files
$ sudo rm -rfv /var/tmp/flatpak-cache-*
This command removes Flatpak cache files, though their size might not be significant.
Remember, some Flatpak packages may be essential to your system, so be mindful of what you uninstall. Always verify the size of packages before removing them. If in doubt, consult the official Flatpak guide for more details on available commands.
Conclusion
After following these steps, you should have successfully reclaimed disk space on your Linux system by cleaning up Flatpak apps. Share your experience in the comments below, and let us know if this guide helped you optimize your disk usage.
Subscribe to the YouTube channel, Medium, and Website, X (formerly Twitter) to not miss the next episode of the Ansible Pilot.Academy
Learn the Ansible automation technology with some real-life examples in my
My book Ansible By Examples: 200+ Automation Examples For Linux and Windows System Administrator and DevOps
Donate
Want to keep this project going? Please donate