Brief: Flatpak is a new universal packaging format from Fedora. Enabling Flatpak will give you access to the easy installation of many Linux applications. Here’s how to use Flatpak in Ubuntu and other Linux distributions.
Installing an application in Linux is as easy as opening the Software Center, searching and installing it. The applications which are not available in the App Stores can be installed via the DEB or RPM packages. Some of them are available via PPAs (for Debian based distributions) and if nothing, one can build from the source code.
There are some limitations though. The App Stores do not generally have the latest release of an application, handling dependencies can be tiresome and the PPAs may not always be safe! And, building from the source requires some terminal hands-on.
With several Linux distributions and the package management systems, there was a need of a Universal Packaging system that could run an application irrespective of what Linux distribution you are using. Canonical thought of it and created Snaps. There is also an independent universal software package called AppImage where you download an application and run it without actually installing the application.
Along with Snaps and AppImage, there is another universal package system called Flatpak from Fedora. We will see how to install and use Flatpak on most Linux distributions along with its advantages.
What is Flatpak?
Flatpak is basically a framework for the applications on Linux. With the different distributions preferring their own package management, Flatpak aims at providing a cross-platform solution with other benefits. It makes the work for developers even easier. A single application build can be used in almost all the Linux distribution (that support Flatpak) without any modification to the bundle.
Primary advantages of Flatpak
- Apart from offering a single bundle for different Linux distributions, Flatpak offers integration to the Linux desktops making it easier to browse, install and use Flatpak applications, e.g. the Gnome Software Center can be used to install a Flatpak.
- Flatpaks are forward compatible i.e. the same Flatpak app can run on the next releases of a distribution without changes.
- Run-time dependencies are maintained which can be used by the application. Missing ones can be added as a part of the application.
- Though Flatpak provides a centralized service for distribution of applications, it fully supports the decentralized distribution of applications.
A. Enable Flatpak support for various Linux distributions
Installing Flatpak is a two-step process. The first one is to install Flatpak so and then we have to add the Flathub repo from where we can install applications.
Install Flatpak on Ubuntu 18.04 and Linux Mint
Linux Mint and Ubuntu 18.04 has Flatpak supported by default. However, you can verify it by trying to install Flatpak again:
sudo apt install flatpak
Install Flatpak on Debian, Ubuntu 17.10, 16.04, Elementary OS and other Ubuntu based distributions
Debian based distros can use the official PPA to install Flatpak. Open a terminal and use the commands below:
sudo add-apt-repository ppa:alexlarsson/flatpak sudo apt update sudo apt install flatpak
Install Flatpak on Red Hat and Fedora based Linux distributions
Since Flatpak is a project developed by Fedora itself, all recent Fedora releases support Flatpak. However, you can still verify it by using the command below:
sudo yum install flatpak
Install Flatpak on openSUSE
To enable Flatpak support on openSUSE based Linux distributions, use the command below:
sudo zypper install flatpak
Install Flatpak on Arch Linux
To enable Flatpak support on Arch based Linux distributions, use the command below:
sudo pacman -S flatpak
B. Enable Flatpak application support in Software Center
Flatpak applications can be completely managed via command line. But not everyone likes using command line for installing applications and this is where enabling Flatpak support in GNOME software center will be a lifesaver.
You will need the GNOME software plugin to install a flatpak via GUI. Use the below command to install it in Ubuntu based distributions:
sudo apt install gnome-software-plugin-flatpak
For other distributions, use the regular package installation command to install gnome-software-plugin-flatpak. Once installed, restart the Software Center or your machine.
Now you can download the .flatpakref file from the application developer’s website or from the official Flatpak application store, Flathub.
Navigate to the download folder and double click on the downloaded .flatpakref file. It should open the Software Center and will provide the installation option as shown in the picture below:
You can also right click on the file and Open with Software Install (default) if double click doesn’t work.
Once the installation completes, you can launch it from software center or from the application menu.
C. Using Flatpak commands (for intermediate to experts)
Now that we have seen how to enable Flatpak support and how to install Flatpak applications, we can move forward to see Flatpak commands for complete control over package installation.
Add repositories for installing Flatpak applications
Flatpak needs to have repository information from where you can find and download applications. It would be a good idea to add the Flathub repository so that you get access to a number of Flatpak applications.
To do that, use the following command:
flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
Searching Flatpak through terminal
You can search for available Flatpak applications using the search option in Flatpak command in the following manner:
flatpak search <application-name>
The application name need not to be exact. It will show all possible results matching the search query.
For example, flatpak search libreoffice returns LibreOffice stable release.
You should note two things in the above command output. The “Application ID” and “Remotes”. You’ll need these two for installing the application.
Install Flatpak applications
The generic way to install a Flatpak command from a repository is:
flatpak install <remote_repository> <application_id>
For example, in the previous search command, you got the Application ID and the repository name. You can use this info to install the application in the following manner:
flatpak install flathub org.libreoffice.LibreOffice
Some developers provide their own repository. You can use the absolute path to the application’s flatpakref to install the application.
flatpak install --from https://flathub.org/repo/appstream/com.spotify.Client.flatpakref
If you have downloaded the .flatpakref file on your system, navigate to the directory and use the command to install it,
flatpak install <package-name>
There are some useful terminal commands which can make your task easier around Flatpak applications.
Run a Flatpak
To run a Flatpak application, you can use the command below:
flatpak run <package-name>
Display all Flatpak apps installed on your system
You can display all Flatpak applications installed on your system using the command below:
Uninstall a Flatpak application
You can use the uninstall option with the application id to remove the installed Flatpak package.
flatpak uninstall <application_id>
Updating all Flatpak applications at once
What do you think of Flatpak?
Enabling Flatpak support certainly provides access to more software. Flathub website provides an easy way of finding these Flatpak applications.
Not only Flatpak addresses the cross-platform application installation among Linux users, it saves efforts to develop separate bundles for different distribution. A single package can be used on various kinds of Linux distributions and the maintenance is super easy.
Though, in comparison to Snap, Flatpak is slightly complicated. Relying on the application id instead of application name is an annoyance in my opinion. I was also surprised that installation and removal of Flatpak application doesn’t require sudo rights.
What do you think about Flatpak and do you use them? Do you prefer it over AppImage or Snaps? Let us know if you face any issue in the comment section.