TranslateProject/sources/tech/20221024.2 ⭐️ How to Clean Up Flatpak Apps to Clear Disk Space.md

5.5 KiB
Raw Permalink Blame History

How to Clean Up Flatpak Apps to Clear Disk Space

**Heres how to clean up Flatpak apps to reclaim your precious disk space. Follow along. **

Flatpak (like Snap) packages run in sandbox mode. By design, it takes a considerable amount of disk space for an individual application, even if it is a smaller one. For example, a simple Test editor or a basic image annotator application can take up more than 100+ MB of storage space.

Its how Flatpak or even Snap operates fundamentally. It pulls all dependencies for an app and runs independently. The advantage of this design is you do not need to worry about dependencies or updates. All you need to do is install and run. On the contrary, it takes up a huge amount of disk space.

And if you are running Ubuntu, elementary OS or any distribution for a longer period, you would be surprised that Flatpak keeps taking up more space over time.

Hence, in this guide, we will give you some commands you can run yourself to clean up flatpak apps.

Clean Up Flatpak

Where Flatpak packages are installed?

When you install a Flatpak package, it gets installed in /var/lib/flatpak. All the installed files, metadata, application files, and runtime files are contained in this directory. Also, the user installation directory contains Flatpak data that is ~/.local/share/flatpak

How to find out the size of Flatpak apps?

There are several commands and parameters of “flatpak” which you can combine to get the desired result to list the applications, size and type of installation. Here are some examples.

  • Verify the size of /var/lib/flatpak. But as it is being used by all Flatpak apps plus runtimes, you may not be able to recover entirely.
du -h /var/lib/flatpak

Size of var-lib-flatpak

Size of var-lib-flatpak

Disk Analyzer Shows Flatpak size

Disk Analyzer Shows Flatpak size

You can use any of the following commands to view the size of installed flatpak packages.

  • View all the installed flatpak with name and installed size.
flatpak --columns=name,size list

flatpak list example 1

flatpak list example 1

  • List all installed flatpak with installation type, size and application ID.
flatpak --columns=app,name,size,installation list

flatpak list example 2

flatpak list example 2

  • View only the flatpak installed by you.
flatpak --columns=name,size --user list

flatpak list example 3

flatpak list example 3

Remember, two types of flatpak may exist in your system. Some of them may be part of the OS itself. And some of them are installed by you.

Commands to Clean up

  • Use the following command to uninstall flatpak packages that are not in use. This is a safe command which you can try.
flatpak uninstall --unused

clean up flatpak using unused switch

clean up flatpak using unused switch

Using the above command, I have freed up around 1GB+ in my test system.

var-lib-flatpak size is reduced

var-lib-flatpak size is reduced

  • If you want to uninstall a specific Flatpak package, use the following command. Change the application ID with the app name. You can find the app name in the above list size commands.
flatpak uninstall <application ID>
  • The following command removes all flatpak packages from your system. Try not to run it unless you are very sure what you are doing. This may break your system, depending on your configuration.
flatpak uninstall --all

Finally, there are some flatpak cache files in path /var/tmp/flatpak-cache-*. Although the size may not be significant. But you can still remove them.

sudo rm -rfv /var/tmp/flatpak-cache-*

For more details about flatpak commands, visit the [official guide][9]. And let me know, using the comment box below, whether this helped you to clean up some space.

If you are looking to clean up Snap packages, the guide is available [here][10].


via: https://www.debugpoint.com/clean-up-flatpak/

作者:Arindam 选题:lkxed 译者:译者ID 校对:校对者ID

本文由 LCTT 原创编译,Linux中国 荣誉推出

[9]: http://flatpak list example 3 [10]: https://www.debugpoint.com/2021/03/clean-up-snap/