Is Flatpak the new shit?

Concepts & Commands

What problem flatpak solves?

Flatpak bundles packages into isolated and portable containers. It supports all distributions and you can install the latest version of your favorite tools without getting lost in the rabbit hole of dependency conflicts and other missing components.

In other words, Flatpak is distribution agnostic and eases software installation by shipping apps with required dependencies.

For some apps, it can be a huuuuge time saver!

How to install

Meh:

sudo apt install -y flatpak # Debian-based distros
sudo dnf install flatpak # CentOS
sudo pacman -S flatpak # Arch distros/Manjaro

But, after that, enjoy \o/.

What is FlatHub?

FlatHub is the home (~ graphical user interface) for hundreds of free apps. You can browse available packages.

It’s also the remote you will likely use when installing packages with Flatpak. In simpler words, it’s the main Flatpak repository.

So, after installing Flatpak, you can type the following:

flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo

Getting the Flatpak’s version

flatpak --version

Searching packages

flatpak search firefox

Simple as that and quite like other package managers. You’ll get important information to install the desired packages correctly, like the Application ID, but also a short description, the version, and even the branch (e.g., stable, 1.xx, etc).

Installing packages

flatpak install [Remote] [Application ID]

The above model gives:

flatpak install flathub org.mozilla.firefox

If you only use the flathub remote, which is likely, you can type:

flatpak install org.mozilla.firefox

Uninstalling packages

flatpak uninstall [Application ID] --delete-data

Which gives:

flatpak uninstall org.mozilla.firefox --delete-data

Listing apps

flatpak list

The above command will list installed Flatpak packages.

Starting apps

Just use your favorite launcher or type:

flatpak run [Application ID]

Which gives:

flatpak run org.mozilla.firefox

Updating packages

flatpak update

Updating a specific package

flatpak update [Application ID]

Which gives:

flatpak update org.mozilla.firefox

Compatibility with Linux environements

You can use the following for GNOME:

sudo apt install -y gnome-software-plugin-flatpak

You’ll get a nice GUI ^^.

Flatpak is also compatible with KDE.

Security: do not go blindly!

Nothing is bulletproof, so the idea with this cheat sheet is not to say Flatpak is perfect.

However, Flatpak do not have too much rights on your system and cannot execute sensitive operations without your explicit permission, which is not the default behavior with traditional package managers.

The term used is “sandbox,” but should be noted that not all security experts agree with the Flatpak approach. Some of them even say Flatpak does not really sandbox apps.

Indeed, the only thing that bothers me is the possibility for an app to require full access to the filesystem, which looks incompatible with the idea of sandboxing.

Some important Cons

  • can be slower than other package managers
  • needs significantly more disk space
  • apps need more RAM and start slowly, in my experience

Credible Alternatives

  • traditional package managers
  • snap (default in Ubuntu)
  • AppImage
  • pacman is totally fine on Arch distros (continuous updates)

More Advanced Concepts & Commands

What are runtimes?

Flatpak uses runtimes, which are sets of essential libraries that can be bundled with packages.

It’s cool but uninstalling apps won’t delete unused runtimes.

That’s why there’s a command to remove unused runtimes.

Removing unused dependencies

flatpak uninstall --unused

Roughly speaking, it’s the equivalent of a sudo apt autoremove.

Listing all remotes

flatpak remotes

Simple as that. It’s helpful when you have multiple remotes. For example, alternative distros may add their own remote.

Adding a new remote

flatpak remote-add [remote]

Modifying the remote

flatpak remote-modify [remote]

Removing the remote

flatpak remote-delete [remote]

More specific Application IDs

Instead of using [Application ID] with the commands, like we saw earlier, you can be more specific:

[Application ID]/[Architecture]/[Branch]

Which gives:

flatpak install org.mozilla.firefox/x86_64/stable

You can use the following to get supported arches:

flatpak --supported-arches

Killing an app

flapak kill [Application ID]

Which gives:

flatpak kill org.mozilla.firefox

What have you done with Flatpak?

flatpak history