How to Install and Use Flatpak

Jarret B

Well-Known Member
Staff member
Joined
May 22, 2017
Messages
372
Reaction score
432
Credits
13,798
I've written other articles that use Flatpak and even cover the installation of Flatpak. In this article, I plan to cover Flatpak in more detail.

Flatpak is a way to install programs on almost all distributions of Linux from a central repository that is compatible with most forms of Linux.

The Flatpak creators say that Flatpak is compatible with 38 different distributions:
  1. AlmaLinux
  2. Alpine
  3. Arch
  4. Ataraxia Linux
  5. CentOS
  6. Chrome OS
  7. Clear Linux
  8. Crystal Linux
  9. Debian
  10. Deepin
  11. Elementary OS
  12. EndeavourOS
  13. Endless
  14. EuroLinux
  15. Fedora
  16. Gentoo
  17. GNU Guix
  18. KDE Neon
  19. Kubuntu
  20. Linux Mint
  21. Mageia
  22. Manjaro
  23. MX Linux
  24. Nix OS
  25. OpenMandriva
  26. OpenSUSE
  27. Pardus
  28. Pisi GNU Linux
  29. Pop!OS
  30. Pure OS
  31. Raspberry Pi OS
  32. Red Hat
  33. Rocky Linux
  34. Solus
  35. Turkman Linux
  36. Ubuntu
  37. Void Linux
  38. Zorin OS
Some of these have Flatpak already installed, but you may need to install Flatpak on your distro.

Flatpak Installation

Before installing, we can see if Flatpak already exists on your flavor of Linux. Use the following to see:

Code:
flatpak --version

I am testing this only on two systems right now. One system is Ubuntu 22.04, and the other is Fedora Workstation 39. Fedora already has Flatpak, but Ubuntu does not.

Installation is easy. Just use the installation command for your OS and install 'flatpak'. For Ubuntu, it would be:

Code:
sudo apt install flatpak

Currently, in Ubuntu, this installs version '1.12.7'. We can use the PPA to install a newer version. For Ubuntu, install 'software-properties-common', then add the repository:

Code:
sudo add-apt-repository ppa:flatpak/stable -y

Now, you can install 'flatpak' again and my version is now '1.14.6'. Any repositories already installed will remain intact.

Once you have the package installed, you can use the command and parameter, '--version', to test it.

Enabling Flatpak

For systems that do not already have Flatpak installed, it is usually not enabled after you install it. You can reboot, or start the service:

Code:
sudo systemctl start flatpak-system-helper

To check the status of the service:

Code:
sudo systemctl status flatpak-system-helper

So, the service is running, but we need to add a 'repository' so it has a place to get files. For Flatpak, it is not named a 'repository', but called a 'remote'.

Adding a Remote

To show that there are no remotes added yet, you can run the command:

Code:
flatpak remotes

For some systems that have Flatpak is already installed, there most likely is a remote already present. For example, on Fedora, there is a 'fedora' remote, as shown in Figure 1.

Figure 1.JPG

FIGURE 1

On other systems, Flatpak had to be installed, so we need to add a remote. The 'default' is to use the 'flathub' remote that is maintained by the Flatpak creators.

Once you have Flatpak installed on your system, the Flatpak commands will be the same on all distributions.

So, add the remote with:

Code:
flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo

The remote is called 'flathub' and is at 'https://flathub.org/repo/flathub.flatpakrepo'. If you list the remotes now, see that 'flathub' was added. For systems that already had Flatpak installed and other remotes, there should be 'flathub' as well, as shown in Figure 2.

Figure 2.JPG

FIGURE 2

Listing Content of Remotes and Installation


You can list the content of the remotes with:

Code:
flatpak remote-ls

We can use 'grep' to search for specific items such as in Figure 3 I searched for 'tux'. The last column shows which 'remote' the program is in. Let's say we want to install 'Super Tux Party'. You can see the line in Figure 4.

Figure 3.JPG

FIGURE 3

Figure 4.JPG

FIGURE 4

Once you have found an application you want to install, you can install it by using the remote and the location, for example 'Super Tux Party' on 'flathub':

Code:
flatpak install flathub party.supertux.supertuxparty

Once it installs, see information similar to that in Figure 5.

Figure 5.JPG

FIGURE 5

Once installation packages are copied and setup, you can list all the packages with the command:

Code:
flatpak list

The file listing will include all dependencies and program files installed by flatpak, as shown in Figure 6.

Figure 6.JPG

FIGURE 6

Removing Packages


If you install a package and then no longer want it, you can remove it. For example, in Figure 6 you can see that I installed 'Surge Engine' from 'org.opensurge2d.OpenSurge', it is a knockoff of the Sonic game. Now, I want to remove it.

Code:
flatpak uninstall flathub org.opensurge2d.OpenSurge

The command is the same one to install the package. Just change the word 'install' to 'uninstall'.

NOTE: If the package name has capitalized letters, be sure to use them. The names are case-sensitive.

Updating Packages

Sometimes you can check if any of the packages have been updated by performing an update on all downloaded packages, if they have updates:

Code:
flatpak update

Like the regular repository list in Linux, the list can be corrupted and may need repaired. You can fix the list with the command:

Code:
flatpak repair

Permissions

From within Flatpak, you can manage permissions for the packages you download. Install 'flatseal'.

Code:
flatpak install flatseal

Notice I did not specify a remote to install from. On Fedora, it will ask you if you want to install it from the Fedora or Flathub remote, since it exists in both.

Once the installation is complete, we can open 'Flatseal' from the menu, or run it from the command-line:

Code:
flatpak run com.github.tchx84.Flatseal

You can run any package from Flatpak with the command, just specify the proper package name. The names can be found from the command 'flatpak list'.

From within Flatseal, you can specify the permissions of each Flatpak package that is on the system. You can enable/disable such as:
  • network
  • bluetooth
  • GPU Acceleration
  • Sound
  • Printing
  • Shared Memory
  • Virtualization
  • and more
Most apps have a configuration that works for it. You can change the permissions, but be aware that removing permissions can cause problems for the app.

If something causes a problem with an app, there is a 'Reset' button at the top of the window, see Figure 7. Resetting any changes back to the original configuration will fix any problems.

Figure 7.JPG

FIGURE 7

Removing Flatpak and Apps


If you simply uninstall Flatpak, the apps that were installed using Flatpak will still be on your system. So, you need to remove the Flatpak apps and then uninstall Flatpak to remove everything.

With Flatpak, you have the main program, installed apps, libraries, app cache and app data to remove or you simply lose space.

If we want to remove as much as possible from the command line, we can:

Code:
flatpak uninstall --all --delete-data

The command will list all installed Flatpak apps and libraries, so you can select whether to uninstall everything listed. After it removes the apps, it will go through each item listed and ask if you want the data removed. If you remove all these items, it will remove the folder '~/.var/apps'. It keeps the following folders:
  • ~/.local/share/flatpak
  • /var/lib/flatpak
If you remove the Flatpak app using 'sudo apt remove', 'sudo yum remove flatpak' or whatever the command is for your distro, it will still not remove the two folders listed above. You'll need to remove these folders if you want to free up the space.

Conclusion

Flatpak is an easy way to install apps on your distro that are not distro dependent.

Try Flatpak to see what apps are available.
 



Members online


Top