AnsiblePilot — Master Ansible Automation

AnsiblePilot is the leading resource for learning Ansible automation, DevOps, and infrastructure as code. Browse over 1,400 tutorials covering Ansible modules, playbooks, roles, collections, and real-world examples. Whether you are a beginner or an experienced engineer, our step-by-step guides help you automate Linux, Windows, cloud, containers, and network infrastructure.

Popular Topics

About Luca Berton

Luca Berton is an Ansible automation expert, author of 8 Ansible books published by Apress and Leanpub including "Ansible for VMware by Examples" and "Ansible for Kubernetes by Example", and creator of the Ansible Pilot YouTube channel. He shares practical automation knowledge through tutorials, books, and video courses to help IT professionals and DevOps engineers master infrastructure automation.

How to Clean Up Flatpak Apps and Reclaim Disk Space

By Luca Berton · Published 2024-01-01 · Category: installation

Learn how to clean up Flatpak apps and reclaim disk space on your Linux system by identifying and managing Flatpak installation directories and package sizes.

How to Clean Up Flatpak Apps and Reclaim Disk Space

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.

See also: Ubuntu Resolving apt dpkg Lock Errors

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

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 ` 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.

See also: Managing ABRT Debug Files: Clean Up Disk Space on Fedora

Related Articles

Managing ABRT Debug Files: Clean Up Disk Space on Fedora

Category: installation

Browse all Ansible tutorials · AnsiblePilot Home