Home Package management How To Remove Unused Flatpak Apps To Free Up Disk Space In Linux

How To Remove Unused Flatpak Apps To Free Up Disk Space In Linux

By sk
1.1K views 4 mins read

In this tutorial, we will explain how Flatpak consumes disk space and the effective commands and techniques to remove unused flatpak apps to reclaim that space.

TL;DR

The main commands to clean up unused flatpak apps are:

  • flatpak uninstall --unused to remove runtimes and extensions no longer needed by any installed app.
  • flatpak repair to fix corrupted or inconsistent objects and remove invalid data.
  • flatpak remove --delete-data --unused to also purge per-app user data that’s orphaned.

Beyond that, you can clear AppStream metadata caches and manually prune leftover object files.

Understanding Flatpak Apps Disk Usage

Flatpak apps run in sandboxes and bundle all libraries they need, which leads to larger disk usage than traditional packages.

Each update may download a full new version of a runtime or extension, then keep the old one around until explicitly removed.

Runtimes (like org.gnome.Platform or org.kde.Platform) are shared by multiple apps, so stale versions accumulate over time if not cleaned.

To understand more about Flatpak disk usage, please visit the following link:

Checking Flatpak Disk Usage

Flatpak stores each application along with its runtimes and extensions in per-user (~/.local/share/flatpak) and system (/var/lib/flatpak) repositories, often leaving unused runtimes behind after updates or uninstalls.

You can inspect how much space Flatpak is using the following commands:

du -sh ~/.local/share/flatpak
du -sh /var/lib/flatpak
Check Flatpak Disk Usage
Check Flatpak Disk Usage

Or list installed runtimes by size:

flatpak list --runtime --columns=application,size

Sample Output:

 --columns=application,size
Application ID                                    Installed size
org.freedesktop.Platform                          604.3 MB
org.freedesktop.Platform                          675.7 MB
org.freedesktop.Platform.GL.default               538.1 MB
org.freedesktop.Platform.GL.default               538.1 MB
org.freedesktop.Platform.GL.default               463.3 MB
org.freedesktop.Platform.GL.default               463.3 MB
org.freedesktop.Platform.VAAPI.Intel               46.9 MB
org.freedesktop.Platform.VAAPI.Intel               51.8 MB
org.freedesktop.Platform.ffmpeg-full               30.4 MB
org.freedesktop.Platform.openh264                 763.9 kB
org.freedesktop.Platform.openh264                 789.5 kB
org.gimp.GIMP.HEIC                                  8.1 MB
org.gnome.Platform                                  1.0 GB
org.gnome.Platform                                  1.0 GB
List Installed Flatpak Runtimes by Size
List Installed Flatpak Runtimes by Size

This helps identify unusually large runtimes or apps.

Removing Unused Flatpak Runtimes and Extensions

Remove all runtimes and extensions no longer required:

flatpak uninstall --unused

This is equivalent to an “autoremove” for Flatpak and can free gigabytes if you haven’t run it in a while.

Purge Orphaned App Data

To also delete user-specific data for uninstalled apps:

flatpak remove --delete-data --unused

This clears out ~/.var/app/<app-id> directories that otherwise linger, reclaiming additional space.

Repairing and Pruning Corrupt or Leftover Files

Fix any broken or inconsistent objects; this can remove invalid files:

flatpak repair
# and for per-user installations
flatpak --user repair

This scans for and deletes any orphaned or corrupted objects.

Clear AppStream Caches

Flatpak maintains AppStream metadata under:

  • ~/.local/share/flatpak/appstream/
  • /var/lib/flatpak/appstream/

You can safely remove these caches; they will be regenerated on next update:

rm -rf ~/.local/share/flatpak/appstream/*
sudo rm -rf /var/lib/flatpak/appstream/*

This can free dozens of megabytes and speeds up metadata queries.

Manual Cleanup of Object Repositories

Sometimes /var/lib/flatpak/repo/objects or ~/.local/share/flatpak/repo/objects holds data from fully uninstalled apps. After confirming you’ve uninstalled everything you don’t need, you can remove these directories entirely:

sudo rm -rf /var/lib/flatpak/repo/objects
rm -rf ~/.local/share/flatpak/repo/objects

Flatpak will recreate them as needed, and you’ll reclaim any leftover blocks.

Automating Regular Cleanup

To avoid future bloat, add a cron job or systemd timer to run cleanup weekly:

sudo nano /etc/cron.weekly/flatpak-clean

Add the following contents in it:

#!/bin/sh
flatpak uninstall --unused -y
flatpak remove --delete-data --unused -y
flatpak repair -y

Make it executable:

sudo chmod +x /etc/cron.weekly/flatpak-clean

This keeps your Flatpak footprint minimal.

Please note that the scripts placed in /etc/cron.weekly/ are executed by the cron daemon on a weekly basis. The exact day and time can vary depending on your system's configuration.

Scripts in /etc/cron.weekly/ are executed as the root user. So just make sure that the commands within the script are safe to run with elevated privileges.

Cheat Sheet

ActionCommand
Remove unused runtimes & extensionsflatpak uninstall --unused
Purge orphaned app dataflatpak remove --delete-data --unused
Repair installationflatpak repair``flatpak --user repair
Clear AppStream cachesrm -rf ~/.local/share/flatpak/appstream/*``sudo rm -rf /var/lib/flatpak/appstream/*
Manual prune of object repossudo rm -rf /var/lib/flatpak/repo/objects``rm -rf ~/.local/share/flatpak/repo/objects

Following these steps will typically recover anywhere from a few hundred megabytes to multiple gigabytes of space, depending on how long you’ve let Flatpak runtimes accumulate without pruning.

You May Also Like

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. By using this site, we will assume that you're OK with it. Accept Read More