Linux flatpak Command
Flatpak is a software distribution and package management tool for Linux. It uses sandbox technology to let applications run in isolated environments. The main advantages of Flatpak include:
- Cross-distribution compatibility: the same Flatpak app can run on different Linux distributions
- Sandbox security: applications run in a restricted environment, enhancing system security
- Dependency isolation: applications bundle their required dependencies, avoiding conflicts with system libraries
- Versioning: supports installing different versions of the same app side by side
Flatpak basic concepts
Runtime
Provides the basic environment needed to run applications, similar to a container's base image.
Application
The actual software package, which depends on a specific runtime.
Remote
A server source that stores Flatpak applications, similar to the software repository of a traditional package manager.
Sandbox
An isolated environment in which applications run, restricting access to system resources.
Flatpak installation and configuration
Install Flatpak
Most Linux distributions can install Flatpak through their package manager:
Example
Ubuntu/Debian
sudo
apt
install
flatpak
Fedora
sudo
dnf
install
flatpak
Arch Linux
sudo
pacman
-S
flatpak
Add the Flathub repository
Flathub is the main Flatpak application repository:
flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
Reboot the system
After installation, it is recommended to reboot so that environment variables take effect.
Common Flatpak commands
Search for applications
flatpak search 应用名称
Install an application
flatpak install 远程仓库 应用ID
For example, to install LibreOffice:
flatpak install flathub org.libreoffice.LibreOffice
List installed applications
flatpak list
Run the application
flatpak run 应用ID
Update applications
Update all installed applications:
flatpak update
Update a specific application:
flatpak update 应用ID
Unmount the application
flatpak uninstall 应用ID
View application information
flatpak info 应用ID
Repair Flatpak
If you encounter problems, you can try to repair:
flatpak repair
Advanced Flatpak usage
Install a specific version of an application
flatpak install 远程仓库 应用ID//版本号
View available versions
flatpak remote-info --log 远程仓库 应用ID
Manage remote repositories
List all configured remote repositories:
flatpak remotes
Delete a remote repository:
flatpak remote-delete 仓库名称
Sandbox permission management
View an application's permissions:
flatpak permissions
Modify an application's permissions:
flatpak override --权限选项 应用ID
For example, to allow an application to access the home directory:
flatpak override --filesystem=home org.gnome.Gedit
Run an older version of an application
flatpak run --commit=版本号 应用ID
Comparison of Flatpak and Snap
| Feature | Flatpak | Snap |
|---|---|---|
| Developing Company | GNOME/Community | Canonical |
| Sandbox technology | Bubblewrap | AppArmor |
| Dependency Management | Shared runtime | Bundles all dependencies |
| Startup speed | Faster | Slower |
| Default repository | Flathub | Snap Store |
| System integration | Good | Average |
| Desktop environment support | Native support for GNOME/KDE | Universal |
| Number of applications | Relatively Many | less |
Common Problem Solutions
1. Application fails to start
Try resetting the application:
Example
flatpak repair
flatpak run
--command
=
bash
Application ID
Enter the application environment for debugging
2. Permission issues
Check and modify permissions:
Example
flatpak permissions
flatpak override --reset-permissions application-ID
3. Insufficient disk space
Clean up old versions and unnecessary runtimes:
flatpak uninstall --unused
4. Inconsistent themes
Install platform theme integration:
flatpak install org.gtk.Gtk3theme.主题名称
Practical Exercise
-
Install the GIMP image editor:
flatpak install flathub org.gimp.GIMP
-
Run GIMP and verify the installation:
flatpak run org.gimp.GIMP
-
Check GIMP's permission settings:
flatpak info org.gimp.GIMP
-
Update all installed Flatpak applications:
flatpak update
-
Uninstall GIMP:
flatpak uninstall org.gimp.GIMP
Summary
Flatpak provides a modern way to distribute applications on Linux, solving dependency conflicts and cross-distribution compatibility issues. Through this tutorial, you should have learned:
- Flatpak's basic concepts and working principles
- The syntax and usage of common commands
- Advanced management and troubleshooting techniques
- The complete workflow for installing and managing real applications
As more developers adopt Flatpak, it is becoming an integral part of the Linux ecosystem.
Linux Command Reference