8

Is there an equivalent of sudo apt clean in snap and flatpak (to delete the cached installation files)?

That might free up a considerable amount of space.

Also, is there any equivalent of sudo apt autoremove, or is it taken care of automatically?

Archisman Panigrahi
  • 25,210
  • 17
  • 90
  • 185

1 Answers1

6

I have not come across one but the following should help:

Snapd

Snap generally preserves at least three revisions (older versions) of any software / package you have installed at any point of time. This makes snapd/cache very bulky. You can set to 1 or 2 using

sudo snap set system refresh.retain=2 // starting from snapd version 2.34

This way you preserver lot of space. Now, clearing the cached installation

sudo rm -rf /var/cache/snapd

flatpak

The analogous process of sudo apt autoremove in flatpak is

flatpak uninstall --unused
Archisman Panigrahi
  • 25,210
  • 17
  • 90
  • 185
  • Even after that [flatpak still use](https://github.com/flatpak/flatpak/issues/1119) a considerable space (`du -hc /var/tmp/flatpak-cache-* | tail -1`). [Probably safe to delete](https://askubuntu.com/a/864398/349837) anyway. – Pablo Bianchi Apr 22 '22 at 23:25
  • For snap, `refresh.retain=1` isn't allowed (`retain must be a number between 2 and 20, not "1"`), and 2 can still be incredibly bulky. Also, changing the setting doesn't immediately free any space. You need to manually [remove old versions](https://superuser.com/questions/1310825/how-to-remove-old-version-of-installed-snaps). – 1j01 Feb 10 '23 at 04:48