A Beginners Guide To Flatpak

install flatpak

A while, we have written about Ubuntu’s Snaps. Snaps are introduced by Canonical for Ubuntu operating system, and later it was adopted by other Linux distributions such as Arch, Gentoo, and Fedora etc. A snap is a single binary package bundled with all required libraries and dependencies, and you can install it on any Linux distribution, regardless of its version and architecture. Similar to Snaps, there is also another tool called Flatpak. As you may already know, packaging distributed applications for different Linux distributions are quite time consuming and difficult process. Each distributed application has different set of libraries and dependencies for various Linux distributions. But, Flatpak, the new framework for desktop applications that completely reduces this burden. Now, you can build a single Flatpak app and install it on various operating systems. How cool, isn’t it?

Also, the users don’t have to worry about the libraries and dependencies, everything is bundled within the app itself. Most importantly, Flaptpak apps are sandboxed and isolated from the rest of the host operating system, and other applications. Another notable feature is we can install multiple versions of the same application at the same time in the same system. For example, you can install VLC player version 2.1, 2.2, and 2.3 on the same system. So, the developers can test different versions of same application at a time.

In this tutorial, we will see how to install Flatpak in GNU/Linux.

Install Flatpak

Flatpak is available for many popular Linux distributions such as Arch Linux, Debian, Fedora, Gentoo, Red Hat, Linux Mint, openSUSE, Solus, Mageia and Ubuntu distributions.

To install Flatpak on Arch Linux, run:

$ sudo pacman -S flatpak

Flatpak is available in the default repositories of Debian Stretch and newer. To install it, run:

$ sudo apt install flatpak

On Fedora, Flatpak is installed by default. All you have to do is enable enable Flathub as described in the next section.

Just in case, it is not installed for any reason, run:

$ sudo dnf install flatpak

On RHEL 7, run:

$ sudo yum install flatpak

On Linux Mint 18.3, flatpak is installed by default. So, no setup required.

On openSUSE Tumbleweed, Flatpak can also be installed using Zypper:

$ sudo zypper install flatpak

On Ubuntu, add the following repository and install Flatpak as shown below.

$ sudo add-apt-repository ppa:alexlarsson/flatpak
$ sudo apt update
$ sudo apt install flatpak

The Flatpak plugin for the Software app makes it possible to install apps without needing the command line. To install this plugin, run:

$ sudo apt install gnome-software-plugin-flatpak

For other Linux distributions, refer the official installation link.

Getting Started With Flatpak

There are many popular applications such as Gimp, Kdenlive, Steam, Spotify, Visual studio code etc., available as flatpaks.

Let us now see the basic usage of flatpak command.

First of all, we need to add remote repositories.

Adding Remote Repositories

Enable Flathub Repository:

Flathub is nothing but a central repository where all flatpak applications available to users. To enable it, just run:

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

Flathub is enough to install most popular apps. Just in case you wanted to try some GNOME apps, add the GNOME repository.

Enable GNOME Repository:

The GNOME repository contains all GNOME core applications. GNOME flatpak repository itself is available as two versions, stable and nightly.

To add GNOME stable repository, run the following commands:

$ wget https://sdk.gnome.org/keys/gnome-sdk.gpg
$ sudo flatpak remote-add --gpg-import=gnome-sdk.gpg --if-not-exists gnome-apps https://sdk.gnome.org/repo-apps/

Applications in this repository require the 3.20 version of the org.gnome.Platform runtime.

To install the stable runtimes, run:

$ sudo flatpak remote-add --gpg-import=gnome-sdk.gpg gnome https://sdk.gnome.org/repo/

To add the GNOME nightly apps repository, run:

$ wget https://sdk.gnome.org/nightly/keys/nightly.gpg
$ sudo flatpak remote-add --gpg-import=nightly.gpg --if-not-exists gnome-nightly-apps https://sdk.gnome.org/nightly/repo-apps/

Applications in this repository require the nightly version of the org.gnome.Platform runtime.

To install the nightly runtimes, run:

$ sudo flatpak remote-add --gpg-import=nightly.gpg gnome-nightly https://sdk.gnome.org/nightly/repo/

Listing Remotes

To list all configured remote repositories, run:

$ flatpak remotes
Name Options
flathub system 
gnome system 
gnome-apps system 
gnome-nightly system 
gnome-nightly-apps system
As you can see, the above command lists the remotes that you have added in your system. It also lists whether the remote has been added per-user or system-wide.

Removing Remotes

To remove a remote, for example flathub, simply do;

$ sudo flatpak remote-delete flathub

Here flathub is remote name.

Installing Flatpak Applications

In this section, we will see how to install flatpak apps. To install a flatpak application

To install an application, simply do:

$ sudo flatpak install flathub com.spotify.Client

All the apps in the GNOME stable repository uses the version name of “stable”.

To install any Stable GNOME applications, for example Evince, run:

$ sudo flatpak install gnome-apps org.gnome.Evince stable

All the apps in the GNOME nightly repository uses the version name of “master”.

For example, to install gedit, run:

$ sudo flatpak install gnome-nightly-apps org.gnome.gedit master

If you don’t want to install apps system-wide, you also can install flatpak apps per-user like below.

$ flatpak install --user <name-of-app>

All installed apps will be stored in $HOME/.var/app/ location.

$ ls $HOME/.var/app/
com.spotify.Client

Running Flatpak Applications

You can launch the installed applications at any time from the application launcher. From command line, you can run it, for example Spotify, using command:

$ flatpak run com.spotify.Client

Listing Applications

To view the installed applications and runtimes, run:

$ flatpak list

To view only the applications, not run times, use this command instead.

$ flatpak list --app

You can also view the list of available applications and runtimes from all remotes using command:

$ flatpak remote-ls

To list only applications not runtimes, run:

$ flatpak remote-ls --app

To list applications and runtimes from a specific repository, for example gnome-apps, run:

$ flatpak remote-ls gnome-apps

To list only the applications from a remote repository, run:

$ flatpak remote-ls flathub --app

Updating Applications

To update all your flatpak applications, run:

$ flatpak update

To update a specific application, we do:

$ flatpak update com.spotify.Client

Getting Details Of Applications

To display the details of a installed application, run:

$ flatpak info io.github.mmstick.FontFinder

Sample output:

Ref: app/io.github.mmstick.FontFinder/x86_64/stable
ID: io.github.mmstick.FontFinder
Arch: x86_64
Branch: stable
Origin: flathub
Date: 2018-04-11 15:10:31 +0000
Subject: Workaround appstream issues (391ef7f5)
Commit: 07164e84148c9fc8b0a2a263c8a468a5355b89061b43e32d95008fc5dc4988f4
Parent: dbff9150fce9fdfbc53d27e82965010805f16491ec7aa1aa76bf24ec1882d683
Location: /var/lib/flatpak/app/io.github.mmstick.FontFinder/x86_64/stable/07164e84148c9fc8b0a2a263c8a468a5355b89061b43e32d95008fc5dc4988f4
Installed size: 2.5 MB
Runtime: org.gnome.Platform/x86_64/3.28

Removing Applications

To remove a flatpak application, run:

$ sudo flatpak uninstall com.spotify.Client

For details, refer flatpak help section.

$ flatpak --help

And, that’s all for now. Hope you had basic idea about Flatpak.

If you find this guide useful, please share it on your social, professional networks and support OSTechNix.

More good stuffs to come. Stay tuned!

Cheers!

Resources:

Thanks for stopping by!

Help us to help you:

Have a Good day!!

You may also like...

3 Responses

  1. john says:

    It was my understanding that Flatpaks aren’t 100% portable. That is, that they sometimes make use of external libraries and folders (like dotFiles, configurations, etc) – thereby bleeding into the system.

    Snap files, otoh, are completely self-contained – similar to static linked binaries and/or Windows portable applications.

    I could be completely wrong here but that was my impression when I was looking up the differences between these two (and others) about a year ago. I love the idea of programs being completely self-contained – to the point of even being able to run them off a USB drive without it effecting the host OS. There may be issues with this scenario that my newbie self is unable to see clearly.

    • Frank says:

      “I could be completely wrong here”

      Yes, you’re wrong here. Flatpaks are more portable than snaps. Flatpak (unlike Snap) has very few dependencies (modern kernel, OSTree) and doesn’t rely on any complex file security system (Snap does rely on AppArmor which makes it less portable) and Flatpak apps run isolated in their own namespace (Snap apps run in the host namespace). They only depend on runtimes which are host-independent, thus don’t reduce portability.

  2. User says:

    I tried flatpak yesterday for installing a less than 1 mb application, more specifically GRadio whose deb install file has exactly only 112,9 kB.
    After going through hell figuring out how to use flatpak, I finally installed it. And right after uninstalled it all and deleted (I hope) everything that has to do with flatpak.

    So… to install a less than 1 mb app I had to install almost 800 mb (yes bigger than a cd-rom capacity) in I have no idea what, for that single tiny app to be able to be installed. I had to type (and learn) a bunch of command lines to use in the terminal…

    We are in 2018, in the era of click-and-done. I really don’t understand why things like this are still made. This was suitable for the ms-dos era, but that is long gone, like by a quarter of a century gone. And even then it would still be 800 mb too big.

Leave a Reply

Your email address will not be published. Required fields are marked *

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