A while ago 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 Snap, there is also another tool called Flatpak. Flatpak is a system to build, install and run applications and runtimes on different Linux distributions. In this tutorial, we will see how to install Flatpak on Linux and the basic usage of Flatpak.
Before Snaps and Flatpaks are developed, packaging applications for different Linux distributions was quite time consuming and difficult process. You can now build a single Flatpak or Snap app and install it on different Linux versions. The users don't have to worry about the libraries and dependencies, everything is bundled within the flatpak 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.
Table of Contents
Install Flatpak On Linux
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 on Debian, 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 18.10 (Cosmic Cuttlefish), simply run:
$ sudo apt install flatpak
On older Ubuntu versions, 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.
A Beginners Guide To Flatpak
There are many popular applications such as Gimp, Kdenlive, Steam, Spotify, Visual studio code etc., available as flatpaks. Allow me to show you the basic usage of flatpak command.
1. Adding Remote Repositories
First of all, we need to add remote repositories that provides the runtimes and flatpak applications.
1.1. Enable Flathub Repository
Flathub is nothing but a central repository where all flatpak applications available to users.
To Flathub repository on Linux, simply run this command:
$ 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.
1.2. 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/
2. 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
3. Removing Remotes
To remove a remote, for example flathub, simply do;
$ sudo flatpak remote-delete flathub
Here flathub is the name of the remote.
4. Install Flatpak applications
In this section, we will see how to install flatpak apps.
To install a Flatpak 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
5. 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
6. Listing applications and runtimes
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
7. Updating applications
To update all your flatpak applications, run:
$ flatpak update
To update a specific application, we do:
$ flatpak update com.spotify.Client
8. 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
9. Removing applications
To remove a flatpak application, run:
$ sudo flatpak uninstall com.spotify.Client
For details, refer flatpak help section.
$ flatpak --help
Recommended read:
Resources:
Thanks for stopping by!
Help us to help you:
- Subscribe to our Email Newsletter : Sign Up Now
- Support OSTechNix : Donate Via PayPal
- Download free E-Books and Videos : OSTechNix on TradePub
- Connect with us: Facebook | Twitter | Google Plus | LinkedIn | RSS feeds
Have a Good day!!
4 comments
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.
“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.
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.
I have to agree with the user above, flatpak requires such a large installation of gnome, (almost 1gb) for a 5mb app in my case.