Getting started with flatpak
A Practical Guide to Sandboxed Apps on Linux
Flatpak is a universal packaging system that lets developers ship applications in a sandboxed environment, independent of the host distribution’s libraries. This guide walks you through installing and configuring Flatpak on the most common Linux distributions, adding the primary Flatpak repository (Flathub), managing applications, handling permissions, and troubleshooting common problems—all in a technical yet approachable style.
Prerequisites
- A recent Linux kernel (most modern distros meet this automatically).
- A working internet connection for downloading packages and repositories.
- Administrative privileges (sudo) for system‑wide installation.
Installation by Distribution
| Distribution | Package Manager | Install Command | Notes |
|---|---|---|---|
| Debian/Ubuntu (and derivatives) | apt | sudo apt update && sudo apt install flatpak |
For Ubuntu 20.04+ the package is in the default repos. |
| Fedora | dnf | sudo dnf install flatpak |
Fedora includes Flatpak in the default repos. |
| CentOS/RHEL 8+ | dnf | sudo dnf install flatpak |
Requires enabling the AppStream repo. |
| Arch Linux | pacman | sudo pacman -S flatpak |
Arch’s community repo. |
| openSUSE Tumbleweed | zypper | sudo zypper install flatpak |
Tumbleweed includes Flatpak. |
| openSUSE Leap | zypper | sudo zypper install flatpak |
Leap 15.4+ includes Flatpak. |
| Gentoo | emerge | sudo emerge --ask app-misc/flatpak |
Use the ~amd64 or ~x86_64 profile. |
Post‑Installation Setup
Add the Flathub repository (the primary source of Flatpak apps):
flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepoFlathub hosts thousands of applications and is the recommended source.
Enable the Flatpak runtime (if not automatically installed):
flatpak install flathub org.freedesktop.Platform//23.08Replace
23.08with the latest platform version.Configure system integration (optional but recommended):
- GNOME:
sudo apt install gnome-software-plugin-flatpak(Debian/Ubuntu) orsudo dnf install gnome-software-plugin-flatpak(Fedora). - KDE:
sudo apt install plasma-discover-flatpak(Debian/Ubuntu) orsudo dnf install plasma-discover-flatpak(Fedora).
- GNOME:
Using Flatpak
- Install an application:
flatpak install flathub org.gimp.GIMP - Run an application:
flatpak run org.gimp.GIMP - List installed applications:
flatpak list - Update all applications:
flatpak update - Remove an application:
flatpak uninstall org.gimp.GIMP
Managing Permissions and Sandboxing
Flatpak uses AppArmor or SELinux profiles to sandbox applications. Permissions can be granted via the flatpak override command:
flatpak override --user --filesystem=home org.gimp.GIMP
This example gives GIMP read/write access to the user’s home directory. For more granular control, consult the Flatpak documentation on “Permissions” and “Sandboxing”.
Troubleshooting Common Issues
| Symptom | Likely Cause | Fix |
|---|---|---|
flatpak: command not found |
Flatpak not installed or PATH not updated | Re‑install or add /usr/bin to PATH |
| Application fails to launch | Missing runtime or incompatible architecture | Install the required runtime (flatpak install flathub org.freedesktop.Platform//...) |
| Network errors during install | Proxy or firewall blocking HTTPS | Configure proxy settings in /etc/flatpak/flatpak.conf or use --proxy flag |
| Permissions denied | App sandbox restrictions | Use flatpak override to grant needed access |
Advanced Topics
- Flatpak Remotes: Add additional remotes beyond Flathub, e.g.,
flatpak remote-add --if-not-exists myrepo https://example.com/repo.flatpakrepo. - Flatpak Snapshots: Use
flatpak snapshotto create a backup of an app’s current state. - Flatpak System vs User Install: By default,
flatpak installinstalls for the current user. Use--systemto install system‑wide (requires root).
Resources for Further Reading
- Official Flatpak documentation: https://flatpak.org/
- Flathub repository: https://flathub.org/
- Distribution‑specific guides (e.g., Arch Wiki, Fedora Docs, Ubuntu Community).
These steps provide a comprehensive workflow for installing, configuring, and managing Flatpak on most Linux systems, ensuring you can take advantage of sandboxed, distribution‑agnostic applications.