Here we will learn what Flatpak is, how to install Flatpak on Linux, and how to use the Flatpak command-line user interface to install, remove, and update Flatpak applications.
Table of Contents
- What is Flatpak?
- Installing Flatpak on Linux
- How to Install Flatpak App
- Flatpak: Pros & Cons
- Conclusion
Package management is probably the most crucial feature of any Linux distro that eases the method of Linux app installation and maintenance. Indeed, nowadays, if you want to download any application, you must’ve come across “Flatpak” or “Flathub.”
Sometimes you need a newer version of a program than is available in the software repositories because it has some new or improved feature you need.
However, you can’t install the version you want on your system because the latest version of that program requires more recent versions of the system libraries than you have.
That’s when something like Flatpak comes into play.
What is Flatpak?
Flatpak makes it possible for users to install applications in an isolated environment known as a “sandbox” decoupled from the underlying operating system. As a result, it is a universal package management system to build, install, and run applications on different Linux distributions.
Flatpak was initially developed by Alexander Larsson and was originally released back in September 2015. Later, it was endorsed by Red Hat, Endless Computers, and Collabora. It is now actively maintained by an independent community composed of contributors, volunteers, and supporting organizations.
Each Flatpak application depends on runtime to work appropriately on a host system and comes bundled with all dependent libraries inside the app. A runtime is nothing but a set of basic dependencies (libraries) required by an application. There are currently three main runtimes available: Freedesktop, GNOME, and KDE.
Installing Flatpak on Linux
Flatpak installation is a two-step procedure. First, to use Flatpak packages, your Linux distro must have Flatpak support.
The most recent versions of some Linux distros, such as Fedora, Linux Mint, elementaryOS, Zorin OS, and Endless OS, come with pre-installed and default Flatpak support.
Here’s how you can add Flatpak’s support by installing the flatpak
package on other Linux distros:
Install Flatpak on Ubuntu, Debian, and Pop!_OS
sudo apt install flatpak
Install Flatpak on AlmaLinux, Rocky Linux, CentOS, and RHEL
sudo dnf install flatpak
Install Flatpak on Arch Linux and Manjaro
sudo pacman -S flatpak
Install Flatpak on openSUSE
sudo zypper install flatpak
For all other Linux distributions, you can check here.
How to Install Flatpak App
Once you finish installing the flatpak
package, you are ready to install Flatpak applications. But before we do that, let’s get aware of the main Flatpak repository – Flathub (https://flathub.org
).
To install Flatpak apps, you need to connect the flatpak
tool to a repository. Flathub is a central Flatpak repository that aims to be the place to get and distribute apps for Linux in Flatpak format. You can browse what’s available on Flathub here.
To enable the Flathub repository to allow you to install applications from Flathub, type the command below:
sudo flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
Search for Flatpak Apps
Once the repository is added, you can check if a particular application is available. You can treat Flatpak as a regular package manager.
You can search for a Flatpak app by using the flatpak search
command. For example, let’s search for Spotify:
flatpak search spotify
The output gives you details about the Flatpak application, such as the Application ID, the version, the branch, and a summary of the application.
Install a Flatpak App
The basic syntax to install applications using Flatpak is flatpak install applicationID
. So, the command to install Spotify will be:
sudo flatpak install com.spotify.Client
Install a Specific Flatpak App Version
Although it is not common practice, you may need to get a specific version of an app rather than the latest version installed by default when installing a Flatpak package.
To demonstrate, we’ll use the Spotify (com.spotify.Client
) Flatpak package as an example. The command below displays all available versions for installation; the identifier you will use for installation is the line “Commit.”
flatpak remote-info --log flathub com.spotify.Client
So, if we want to install, say, the penultimate version available, the command to use is:
sudo flatpak update --commit=60f1d52b28a0119214e9f68401de94593ffd26dbf3c77f7402582e3f274e2fa8 com.spotify.Client
It’s worth noting that because we’re using the update
option, you must already have installed the Flatpak package before you can downgrade to an older version.
Run a Flatpak App
Running a Flatpak is quite simple. For example, in our case, here is what the command will look like:
flatpak run com.spotify.Client
Of course, you can run the app like any other from the App Launcher you use.
List Installed Flatpak Apps
You can list all the currently installed Flatpak apps by running the command shown below:
flatpak list
Update Installed Flatpak Apps
To update Flatpak packages within your system, run:
flatpak update
Keep in mind that if all packages are already up to date, there will be no new changes after running the above command.
Uninstall a Flatpak App
Finally, removing it is quite a simple operation if you don’t need the Flatpak application anymore. The syntax of the command is flatpak uninstall applicationID
.
For example, to remove Spotify, execute the command:
sudo flatpak uninstall com.spotify.Client
We should also mention one feature. When you uninstall a Flatpak application, the user data for that app is retained on your system. They are usually saved in ~/.var/app
.
To remove this data during uninstallation, use the --dalete-data
option. As a result, the above command would look like this:
sudo flatpak uninstall --delete-data com.spotify.Client
Removing Unused Flatpak Runtimes
It is a good practice to clean your system and free up space from time to time. You can remove the unused Flatpak runtimes by using the command shown below:
flatpak uninstall --unused
Flatpak: Pros & Cons
Without a doubt, Flatpak has revolutionized package management in Linux. But like any other technology, this one comes with its good and not-so-good sides. So, let’s summarize them.
Pros
- Build for every distro – You can install Flatpak packages on any distro you want. In other words, you can create one app and distribute it to the entire Linux desktop market.
- Application sandboxing – All applications are limited to a set of predefined permissions, enhancing privacy and security.
- Up-to-date package versions – The Flatpak packages on flathub.org can be more up-to-date than the various Linux distributions offered in their repositories.
- OS safety – Because none of your system libraries are upgraded, you do not risk instability or problems with your other programs or operating system.
- Easy to use – Offers easy integration with an existing software center on your Linux distribution.
Cons
- “Bloated” than native apps – Many Flatpak packages have dependencies, which tend to be gigantic. For example, a simple Calculator app can take up more than 300+ MB of storage space.
- Memory usage – Each app with a new runtime adds another hundred megabytes or more RAM usage.
- Speed – The Flatpak apps have to load all their libraries from disk instead of using what’s already on the system or in memory. This slows down the time they need to get started. Of course, once running, they should not be slower than regular packages.
Conclusion
I hope that now you have a good idea of what Flatpak is all about. First, it makes installing applications easy for the user by eliminating version conflicts.
Moreover, it’s good when you want to use applications that are not in your distribution’s repository or if you require a newer version of an application.
For additional help or useful information, I recommend checking the official Flatpak website.
Feel free to express your opinion or ask any doubt in the comments section below.