How to Use Flatpak on Linux: A Comprehensive Guide

Master Flatpak on Linux. Learn how to install, update, and remove Flatpak applications effortlessly with our comprehensive guide.

Flatpak has gained popularity among Linux users and developers due to its potential to simplify software distribution, increase security, and provide a consistent application experience across different Linux distributions.

Let me give you an example. Sometimes you may need a newer version of an application that is unavailable in the repositories of your distribution. Or even the application itself is not available there.

But even if you find a package of this software available somewhere for the package manager used by your system, you may not be able to install it. Why?

Because for example, the latest version of that program requires different versions of the system libraries than you have, and here is where Flatpak comes into play.

What Is Flatpak?

Flatpak is a package management and software distribution system for Linux-based operating systems. It allows users to install applications in an isolated sandbox environment decoupled from the underlying operating system.

It is designed to provide a consistent and secure way to package, distribute, and run applications across different Linux distributions, regardless of their underlying libraries and dependencies.

As a result, it is a universal package management system to build, install, and run applications on different Linux distributions.

How Ftlatpak Works?

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 a set of basic dependencies (libraries) an application requires. The most commonly used ones are Freedesktop, GNOME, and KDE.

One of the significant advantages of the Flatpak is that libraries are reused as needed, so they are not installed for every package.

For example, the Dolphin file manager would be equivalent in size if you installed it on an entirely new system, whether you use the Flatpak or the system’s native package manager.

However, if you install it as a Flatpak application since the required Qt libraries will be available on the system, the next Qt application you install that uses Qt will take up significantly less space.

At the same time, you need to keep something else in mind. If you have to use Flatpaks extensively, you can expect to have a lot of duplicated runtimes because many applications use different versions of those runtimes. In other words, the dependencies are still reused, but only when possible.

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, etc., come with Flatpak support out-of-the-box. In other words, there is no need to install such support on them.

The easiest way to check if you have Flatpak installed is by running, for example:

flatpak listCode language: PHP (php)
Check if Flatpak is installed.
Check if Flatpak is installed.

If you receive command output similar to the one shown above, all is well, and your system has the necessary Flatpak support.

However, if you get a message like the one below, “Command ‘flatpak’ not found…” you can easily install it depending on the Linux distribution you are using with any of the below-provided commands.

Check if Flatpak is installed.
Check if Flatpak is installed.

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 you do that, let’s get aware of the central Flatpak repository – Flathub (https://flathub.org).

Flathub website.
Flathub website.

To enable the Flathub repository to allow you to install applications from there, type the command below:

sudo flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepoCode language: JavaScript (javascript)

Search for Flatpak Apps

Once the repository is added, you can check if a particular application is available. So 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
Installing Flatpak Package

The output gives you details about the Flatpak application, such as the Application ID, version, branch, and application summary.

Install a Flatpak App

The basic syntax to install applications using Flatpak is flatpak install applicationID. So, the command to install Spotify will be:

flatpak install com.spotify.ClientCode language: CSS (css)
Flatpak Installation Succeeded

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.

We’ll use the Spotify (com.spotify.Client) Flatpak package as an example to demonstrate. 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.ClientCode language: CSS (css)
Install a specific flatpak app version

So, if we want to install, say, the penultimate version available, the command to use is:

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.ClientCode language: CSS (css)

Of course, you can run the app like any other from the App Launcher you use.

Running Flatpak App

List Installed Flatpak Apps

You can list all the currently installed Flatpak apps by running the command shown below:

flatpak listCode language: PHP (php)
List locally installed Flatpak apps

Update Installed Flatpak Apps

To update Flatpak packages within your system, run the following:

flatpak update
Updating Flatpak Apps

Keep in mind that if all packages are already up to date, there will be no new changes after running the above command.

Updating Flatpak Apps

Uninstall a Flatpak App

Finally, removing it is quite a simple operation if you no longer need the Flatpak application. The syntax of the command is flatpak uninstall applicationID.

For example, to remove Spotify, execute the command:

flatpak uninstall com.spotify.ClientCode language: CSS (css)
Uninstalling Flatpak App

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 --delete-data option. As a result, the above command would look like this:

flatpak uninstall --delete-data com.spotify.ClientCode language: CSS (css)

Removing Unused Flatpak Runtimes

It is a good practice to clean your system and free up space occasionally. You can remove the unused Flatpak runtimes by using the command shown below:

flatpak uninstall --unused
Removing Unused Flatpak Packages

Flatpak: Pros & Cons

Without a doubt, Flatpak has revolutionized package management in Linux. But like any other technology, this one has good and not-so-good sides. So, let’s summarize them.

Pros

  • Distro-agnostic: 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 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

Flatpak is a powerful tool that allows Linux users to easily install and run applications in a secure and sandboxed environment.

With its cross-distribution compatibility and simplified packaging process, Flatpak has gained popularity in the Linux community as a way to distribute and manage software eliminating version conflicts.

Moreover, it’s good when you want to use applications not in your distribution repository or require a newer version of an application.

In this comprehensive guide, we have explored the basics of Flatpak, including how to install it, set up repositories, search and install applications, and manage updates.

For additional help or useful information, check the official Flatpak documentation.

Feel free to express your opinion or ask questions in the comments below.

Bobby Borisov

Bobby Borisov

Bobby, an editor-in-chief at Linuxiac, is a Linux professional with over 20 years of experience. With a strong focus on Linux and open-source software, he has worked as a Senior Linux System Administrator, Software Developer, and DevOps Engineer for small and large multinational companies.

Think You're an Ubuntu Expert? Let's Find Out!

Put your knowledge to the test in our lightning-fast Ubuntu quiz!
Ten questions to challenge yourself to see if you're a Linux legend or just a penguin in the making.

1 / 10

Ubuntu is an ancient African word that means:

2 / 10

Who is the Ubuntu's founder?

3 / 10

What year was the first official Ubuntu release?

4 / 10

What does the Ubuntu logo symbolize?

5 / 10

What package format does Ubuntu use for installing software?

6 / 10

When are Ubuntu's LTS versions released?

7 / 10

What is Unity?

8 / 10

What are Ubuntu versions named after?

9 / 10

What's Ubuntu Core?

10 / 10

Which Ubuntu version is Snap introduced?

The average score is 68%

3 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *