1. Overview
In this tutorial, we’ll learn how to use the Flatpak package manager, add new repositories to search for applications, install packages and manage applications on a Linux system.
Flatpak is a utility for software deployment and package management that offers a sandbox environment that allows users to run applications in isolation from the rest of the system.
2. Advantages of Using Flatpak
Flatpak offers many advantages as a package manager:
- Flatpak apps can be installed on any Linux distribution that supports Flatpak
- We can add repositories to find and download apps; therefore, it supports the decentralized distribution of apps
- Flatpak keeps apps isolated from the rest of the system; therefore, it is more secure
- Flatpak apps are forward compatible; that is to say, the same Flatpak app can run on the next releases of a Linux distro without any updates required
- We don’t need to worry about dependencies/libraries that the program requires to run when working with Flatpak
With all that said, let’s learn how to use Flatpak.
3. Installing Flatpak
First, we have to install Flatpak.
3.1. On Ubuntu/Debian
We should run these commands:
$ sudo add-apt-repository ppa:alexlarsson/flatpak
$ sudo apt update
$ sudo apt install flatpak
After that, we can check if Flatpak is installed:
$ flatpak --version
Flatpak 1.12.7
We have successfully installed Flatpak.
3.2. On Fedora
We should run dnf install:
$ sudo dnf install flatpak
3.3. On CentOS and Other Red-Hat Based Distros
We can use the yum package manager:
$ sudo yum install flatpak
3.4. On OpenSUSE
We should use zypper:
$ sudo zypper install flatpak
3.5. On Arch Linux
We should use the pacman package manager:
sudo pacman -S flatpak
4. Adding a Repository
Next, we’ll have to add a repository to be able to look for and install apps. Let’s add the most popular one, Flathub:
$ flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
Now we can download and install many apps that are located on the Flathub repository.
5. Searching for Applications
Before installing apps, we can search for them and get more information about them by running flatpak search:
$ flatpak search discord
Name Description Application ID Version Branch Remotes
Discord Messaging, Voice, and Video Client com.discordapp.Discord 0.0.17 stable flathub
...
We found the app we wanted to install. And we found more information about the package, including its version, application ID, branch, and remote repositories. We need this information to install the app later.
6. Installing an Application
There are two ways we can install an app on a Linux machine:
6.1. Through GUI
To install an app through GUI, we need to install a plugin that enables Flatpak app support in the distro’s Software Center:
$ sudo apt install gnome-software-plugin-flatpak
After the installation is finished, we can download a .flatpakref file from an app developer’s website or from Flathub. After that, we can simply double-click on the file and open it in the Software Center to install it:
The Software Center will download and install the app on the Linux machine.
6.2. Through CLI
To install an app through CLI, we need its application ID and the name of its remote repository:
$ flatpak install [remotes] [application ID]
We’ve already received this information from the flatpak search output:
$ flatpak install flathub com.discordapp.Discord
Flatpak will download and install the app.
Alternatively, we can install the app from a .flatpakref file. We can download a .flatpakref file from Flathub or from an app developer’s website:
$ flatpak install com.discordapp.Discord.flatpakref
Flatpak will download and install the app.
7. Running a Flatpak Application
To run a Flatpak app, we can simply look for it in the Application Menu and then open it. Alternatively, we can use Flatpak itself to launch the application:
$ flatpak run [application ID]
For example:
$ flatpak run com.discordapp.Discord
We’ve already received the application ID information from the flatpak search output*.*
8. Updating Applications
To update a Flatpak app installed on the Linux system, run flatpak update with the application ID:
$ flatpak update [application ID]
For example:
$ flatpak update com.discordapp.Discord
Looking for updates…
Nothing to do.
No updates were found since we’d already installed the newest version.
Moreover, to update all Flatpak apps installed on the Linux machine, we can run flatpak update:
$ flatpak update
Looking for updates…
Nothing to do.
No updates were found.
9. Listing All Flatpak Applications
To list all Flatpak apps on a Linux system, we can run flatpak list:
$ flatpak list
This will list all the installed Flatpak apps.
10. Removing a Flatpak Application
To uninstall a Flatpak app, we can run flatpak uninstall:
$ flatpak uninstall [application ID]
For example:
$ flatpak uninstall com.discordapp.Discord
Flatpak will remove the app from the machine.
11. Conclusion
To sum up, we learned how to work with Flatpak, a package manager with many advantages.
Working with Flatpak can be slightly challenging for the average user compared to some other package managers like Snap through CLI since it requires application IDs instead of application names. On the other hand, new Linux users can always install Flatpak apps through GUI.