Flatpak is a universal package system for software deployments, application virtualization, and most importantly package management that works on all Linux distros. With a Flatpak package, you don’t need to worry about any dependencies and libraries as everything is already bundled within the application itself. A notable feature of Flatpak is that all apps work in a sandbox approach which means that they all work in isolation. Among other things, this feature lets you run various versions of a software on the same system.
In this article, we will describe installing Flatpak on your Ubuntu through the official Ubuntu repository and also through the Alexander Larsson PPA repository. The later repository mostly gets you the latest version of Flatpak on your Ubuntu. We will also explain how you can use Flatpak to install software through the Ubuntu command line and through the Ubuntu software Manager.
We have run the commands and procedures mentioned in this article on a Ubuntu 18.04 LTS system.
Install Flatpak through Ubuntu Official Repository
Flatpak is easily available through the official Ubuntu repository and can be installed through the command line using the apt-get command.
Open your Terminal application either through the system Application Launcher Search or through the Ctrl+Alt+T shortcut.
The next step is to update your system’s repository index through the following command:
$ sudo apt-get update
This helps you in installing the latest available version of software from the Internet. Please note that only an authorized user can add, remove and configure software on Ubuntu.
Now you are ready to install Flatpak; you can do so by running the following command as sudo:
$ sudo apt-get install flatpak
The system might ask you the password for sudo and also provide you with a Y/n option to continue the installation. Enter Y and then hit enter; the software will be installed on your system. The process may, however, take some time depending on your Internet speed.
You can check the version number of the application, and also verify that it is indeed installed on your system, through the following command:
$ flatpak --version
Through the Alexander Larsson PPA (for latest version)
While writing this article, I got to install Flatpak through the official Ubuntu repositories and the Alexander Larsson PPA and it reassured that the later provides you with the latest version of the software. Please follow these steps in order to install Flatpak from this PPA:
Open the Terminal application and enter the following command as sudo in order to add the Alexander Larsson PPA to your system:
$ sudo add-apt-repository ppa:alexlarsson/flatpak
Enter the password for sudo, after which the PPA repository will be added to your system.
Tip: Instead of typing the command, you can copy it from here and paste in the Terminal by using the Ctrl+Shift+V, or by using the Paste option from the right-click menu.
The next step is to update your system’s repository index through the following command:
$ sudo apt-get update
This helps you in installing the latest available version of software from the Internet.
Now that you are done with adding the PPA, use the following apt-get command as sudo in order to install Flatpak to your system:
$ sudo apt-get install flatpak
Now the system will pick the Alexander Larsson PPA to install the software from.
You can check the version number of the installed software through the following command:
$ plank --version
The version installed through the PPA is definitely newer than the one I installed from the official Ubuntu repositories.
Install Software through Flatpak using the Command Line
As an example of installing software through the Flatpak installer using the command line, we will search for and install the GNU Octave package. GNU Octave is a high-level interpreted language, primarily intended for numerical computations.
In order for Flatpak to know where to find and download an application package from, you need to add the Flathub repository. This repository gives you a number of Flatpak applications to choose from. Add the Flathub repo as follows:
$ flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
The following dialog will ask you to provide authentication details for sudo:
Please provide the password and the Flathub repository will be added to your system.
You can now search for an application through the following command syntax:
$ flatpak search [application-name]
I used the following command to search for GNU Octave:
$ flatpak search octave
The search result gives you an Application ID which you can use in the following command to add a specific package:
$ flatpak install flathub [Application_ID]
I would install the GNU Octave package from the Flathub repo, using the flatpak installer, as follows:
$ flatpak install flathub org.octave.Octave
Enter Y to start the installation procedure. The Octave package is around 1.3 GB in size and might take long depending on your Internet speed after which it will be installed on your system.
Install Software through Flatpak using the Software Manager UI
When you search for a package in the Ubuntu Software Manager, it does not list the packages available on Flatpak. For example, when I tried searching for the gedit editor, Ubuntu Software only listed the package from GNOME:
If you want Flatpak support in the Software Center so that it also lists Flatpak application packages, you need to install a plugin.
Use the following command as sudo in your Terminal to install the required plugin:
$ sudo apt-get install gnome-software-plugin-flatpak
Enter Y on the Y/n prompt and the plugin will be installed and also automatically configured with the Software Manager.
Now when I searched for gedit again, I could see the gedit Flatpak package listed in the search results.
You can search for any such package and then proceed with the installation like you would for any other software.
This was all you needed to know about Flatpak. If you want, you can remove it through the following commands:
$ sudo apt-get remove flatpak
If you have installed the package from the PPA, you can remove the PPA through the following command:
$ sudo rm /etc/apt/sources.list.d/alexlarsson-ubuntu-flatpak-bionic.list
You can now access the latest versions of most applications through the Flatpak universal package system.