Flatpak lets you install desktop apps on Linux in a way that works the same on almost every distribution. Each app brings the libraries it needs and runs in a sandbox, apart from the rest of the system. Flathub is the main app store for Flatpak apps.
What it means
Most Linux apps come from the distribution itself: the version of Linux that you use. Ubuntu, Fedora and Arch Linux each package the same apps on their own. So one app can look different, or be an older version, depending on the system. App makers also have to deal with many different systems.
Flatpak takes another approach: one package that works everywhere. Picture a camping kit with its own tent, stove and water. You can set it up in any field, and you need nothing from the farmer. A Flatpak app carries what it needs in the same way.
Each app also runs in a sandbox. It works like a separate room. The app cannot look into the rest of your house unless you open a door for it, so a bad or broken app has a harder time harming your files.
You may already have it. Fedora, Linux Mint and Pop!_OS are among the many distributions that include Flatpak, and the software center often uses it without you noticing.
Back to topHow to use it
Start by checking whether Flatpak is on your system:
flatpak --version
This shows which version of Flatpak you have.
If Flatpak is missing, install it with your package manager. On Debian and Ubuntu:
sudo apt install flatpak
This installs Flatpak from the packages of your distribution.
Next, add Flathub as a source of apps:
flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
This tells Flatpak where to find the Flathub apps.
Log out and log in again so that new apps show up in your menu. After that, you can search for apps and install them. Each app has its own ID. The VLC media player, for example, uses org.videolan.VLC:
flatpak search vlc
flatpak install flathub org.videolan.VLC
flatpak run org.videolan.VLC
These three commands search for VLC, install it from Flathub and start it.
For daily use, these commands help:
flatpak list --appshows the apps you installed.flatpak updateupdates all apps and runtimes.flatpak uninstall org.videolan.VLCremoves an app.flatpak uninstall --unusedremoves runtimes that no app needs anymore.
How it works
A Flatpak app does not use the libraries of your system. Instead, it relies on a runtime: a shared set of base libraries, such as the GNOME, KDE or Freedesktop runtime. Many apps share one runtime, so you download it only once. The app package then holds only what the runtime does not provide.
Flatpak stores apps and runtimes with OSTree, which works a bit like Git for files. Identical files exist only once, and an update downloads only the changes. Apps installed for all users live in /var/lib/flatpak. Apps installed with --user go to ~/.local/share/flatpak.
bubblewrap and Linux namespaces form the sandbox. By default, an app cannot see your home folder or other apps. Each app declares the permissions it needs, such as network access or access to the Downloads folder. You can view these permissions and change them:
flatpak info --show-permissions org.videolan.VLC
flatpak override --user --nofilesystem=home org.videolan.VLC
The first command lists the permissions of VLC, and the second removes its access to your home folder.
Portals reduce how much access many apps need. To open a file, the app asks a portal. The portal shows the normal file dialog outside the sandbox. The app then gets access only to the file that you picked.
There is one pitfall. A sandbox is only as strict as its permissions, so an app with access to your whole home folder can read all of your files. The Flathub website shows the permissions of each app before you install it. Check that list first, and use flatpak override to remove access that an app does not need.
