flatpak Command in Linux

Introduction to Flatpak on Linux

This tutorial explores Flatpak, a next-generation package management solution for Linux environments. Flatpak provides a secure and consistent method for installing and managing applications by isolating them within sandboxed environments. Learn how to leverage Flatpak for streamlined application management on your system. We'll cover installing Flatpak, enabling the Flathub repository, searching for, installing, and managing applications on an Ubuntu 22.04 system. We will also cover how to customize Flatpak environments to suit specific systemadmin needs.

Understanding Flatpak: A Systemadmin's Guide

This section provides a comprehensive introduction to Flatpak package management for Linux. Flatpak represents a modern approach to application installation and management, offering enhanced security and consistency through application isolation.

Let's begin by installing the Flatpak package on your Ubuntu 22.04 system:

sudo apt install -y flatpak

Example output:

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  dbus-x11 flatpak-session-helper libdconf-dbus-1-0 libflatpak0 libostree-1-1 libsoup2.4-1 libsoup2.4-dev libsoup2.4-doc libsoup2.4-gir libsoup2.4-gir-dev
  libsoup2.4-lang
Suggested packages:
  libsoup2.4-dev
The following NEW packages will be installed:
  dbus-x11 flatpak flatpak-session-helper libdconf-dbus-1-0 libflatpak0 libostree-1-1 libsoup2.4-1 libsoup2.4-dev libsoup2.4-doc libsoup2.4-gir libsoup2.4-gir-dev
  libsoup2.4-lang
0 upgraded, 11 newly installed, 0 to remove and 0 not upgraded.
Need to get 3,095 kB of archives.
After this operation, 15.5 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y

Next, enable the Flathub repository to broaden your application selection:

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

Example output:

Added remote flathub

With Flatpak installed and Flathub enabled, you can now explore and install applications. The following section guides you through managing Flatpak applications.

Managing Flatpak Applications on Ubuntu 22.04

This section focuses on installing, running, and managing Flatpak applications within an Ubuntu 22.04 environment.

Start by searching for Flatpak applications within the Flathub repository. This example searches for the GIMP image editor:

flatpak search gimp

Example output:

Name                 Description                       Version Branch        Remotes
org.gimp.GIMP         The GNU Image Manipulation Program 2.10.30 stable       flathub

To install GIMP as a Flatpak, use the following command. The `sudo` command is not necessary unless installing system-wide.

sudo flatpak install flathub org.gimp.GIMP

Example output:

Looking for matches...
Found remote 'flathub'
Resolving dependencies...
Downloading metadata...
Downloading: org.gimp.GIMP/x86_64/stable (1/1)
Importing: org.gimp.GIMP/x86_64/stable (1/1)
Installation complete.

Launch GIMP using Flatpak with this command:

flatpak run org.gimp.GIMP

This command initiates GIMP within the secure, isolated environment provided by Flatpak.

Effectively manage installed Flatpak applications using these commands:

List all Flatpak applications installed on your system:

flatpak list

Update all installed Flatpak applications to their latest versions:

sudo flatpak update

Remove a Flatpak application from your system:

sudo flatpak uninstall org.gimp.GIMP

The next section will cover customizing the Flatpak environment.

Advanced Flatpak Customization for Systemadmins

This section explores the customization options available within Flatpak environments, allowing systemadmins to tailor the application experience to specific requirements.

Flatpak allows for the creation of custom runtime environments for applications. Runtimes provide the foundational libraries and dependencies necessary for application execution. Custom runtimes give control over the exact library versions and dependencies used by each application, mitigating conflicts and ensuring compatibility. This is particularly useful when older or very specific versions of libraries are needed. This may require root privileges.

As an example, here's how you might start to build a custom runtime for GIMP:

## Create a new Flatpak runtime
flatpak remote-add --if-not-exists flathub-beta https://flathub.org/beta-repo/flathub-beta.flatpakrepo
flatpak install flathub-beta org.gnome.Platform//43

## Create a custom GIMP runtime based on the GNOME platform
flatpak build-init gimp-runtime org.gimp.GIMP org.gnome.Platform//43
flatpak build gimp-runtime flatpak install flathub org.gimp.GIMP
flatpak build-finish gimp-runtime
flatpak build-export ~/project/gimp-runtime gimp-runtime

Install and launch GIMP using your custom runtime:

flatpak install ~/project/gimp-runtime org.gimp.GIMP
flatpak run org.gimp.GIMP

This command ensures GIMP runs within your defined runtime environment, utilizing your chosen libraries and dependencies. Remember that the user must have permissions on the path specified for `gimp-runtime`.

Fine-tune your runtime further by adjusting dependencies, environment variables, and other parameters within the gimp-runtime directory.

Conclusion: Flatpak for Efficient Linux Application Management

This tutorial demonstrated the power of Flatpak, a modern package management tool that allows systemadmins to manage their software in a secure and consistent manner on Linux systems. We covered Flatpak installation, Flathub repository integration, and the core functions for installing and managing Flatpak packages. Finally, we touched upon customizing Flatpak runtimes, application sandboxing for advanced control over application environments.

400+ Linux Commands