4 of 4

Software ManagementLesson 4 of 4

Flatpak remotes and applications

Add a Flatpak remote, install an application from it, run it, update it and remove both again.

  • flatpak
  • flatpak remote-add
  • flatpak remotes
  • flatpak search
  • flatpak install
  • flatpak list
  • flatpak run
  • flatpak uninstall
  • flatpak remote-delete

35 min5 exercises

After this lesson you can

  • Explain what Flatpak adds to RPM and DNF, and the difference between system and user installations.
  • Add, list and remove a Flatpak remote, then install, list, run, update and uninstall an application.
  • Work with a remote that is local or unsigned, as in an offline exam or lab.

The idea

RPM packages are built for one distribution, and share libraries with the rest of the system. A Flatpak is an application packaged together with a runtime (the libraries it needs), installed in its own sandbox. That lets one application version run on many Linux versions, independent of the system’s own package versions. Red Hat added Flatpak management to the RHCSA objectives because desktop and some vendor applications are distributed this way.

Vocabulary:

TermMeaning
RemoteA Flatpak repository, like a DNF repository but with a name and a URL
Application IDA reverse-domain name such as org.gnome.Calculator, used to refer to the app
RuntimeShared libraries an application needs; installed automatically
Installationsystem (all users, needs root) or user (just you, no root)

The parallels with DNF make it easy to remember:

TaskDNFFlatpak
Add a sourcewrite a .repo fileflatpak remote-add NAME URL
List sourcesdnf repolistflatpak remotes
Searchdnf searchflatpak search
Installdnf installflatpak install REMOTE APPID
List installeddnf list installedflatpak list
Updatednf upgradeflatpak update
Removednf removeflatpak uninstall APPID

By default flatpak commands act on the system installation, and installing needs root (or polkit authorisation). --user works in your home without root and affects only you. In an exam or on a server, use the system installation unless told otherwise, and be consistent: an app installed with --user is invisible to flatpak list without that option.

Try it

rpm -q flatpak || sudo dnf install -y flatpak
flatpak --version
Flatpak 1.16.1

Add a remote

sudo flatpak remote-add --if-not-exists lab-remote https://dl.flathub.org/repo/flathub.flatpakrepo
flatpak remotes
Name        Options
lab-remote  system

The URL ends in .flatpakrepo, a small description file that carries the remote’s address and signing key. Red Hat publishes its own remote for supported applications, and the exact URL and any login it needs are in the official documentation; on an exam system the task states the location to use.

Install, inspect, run

flatpak search calculator | head -3
sudo flatpak install -y lab-remote org.gnome.Calculator
flatpak list
Name        Application ID                 Version Branch Remotes
Calculator  org.gnome.Calculator           47.0    stable lab-remote
Name        Application ID                 Version Branch Origin     Installation
Calculator  org.gnome.Calculator           47.0    stable lab-remote system
flatpak info org.gnome.Calculator | head -6
flatpak run org.gnome.Calculator
Calculator - Perform arithmetic, scientific or financial calculations

          ID: org.gnome.Calculator
         Ref: app/org.gnome.Calculator/x86_64/stable
        Arch: x86_64
      Branch: stable
     Version: 47.0

Update and remove

sudo flatpak update -y
sudo flatpak uninstall -y org.gnome.Calculator
sudo flatpak uninstall -y --unused
sudo flatpak remote-delete lab-remote

Uninstalling an app leaves its runtimes behind; --unused removes runtimes nothing needs any more. remote-delete fails while applications from that remote are still installed, so remove the apps first.

An unsigned or local remote

A repository you built yourself, or one served inside a lab, may have no signing key. --no-gpg-verify skips the check:

sudo flatpak remote-add --if-not-exists --no-gpg-verify internal http://repo.example.com/flatpak
flatpak list --columns=application,origin

Going further

flatpak remote-ls REMOTE lists everything a remote offers, and flatpak remote-modify changes a remote’s settings. flatpak override adjusts an app’s sandbox permissions, for example --filesystem=/data. flatpak history shows past operations, and flatpak repair fixes a damaged installation. flatpak install --noninteractive and -y are for scripts. Flatpak applications are updated separately from RPM packages, so dnf upgrade does not touch them: schedule flatpak update as well if you keep apps installed.

Practice

0 of 5 done

Do these on your own system. They get harder. Check each result, then tick it off.

  1. Warm-up

    Make sure Flatpak is available

    Check whether the flatpak command exists. If not, install it with DNF. Show its version and the list of configured remotes (there may be none).

    Check your result

    flatpak --version prints a version. flatpak remotes prints a table, possibly empty.

    Hint

    rpm -q flatpak, sudo dnf install -y flatpak.

    Solution
    rpm -q flatpak || sudo dnf install -y flatpak
    flatpak --version
    flatpak remotes
  2. Practice

    Add a remote

    Add a system-wide Flatpak remote named lab-remote from the URL given in your task (for example https://dl.flathub.org/repo/flathub.flatpakrepo if your lab has internet). Do not fail if it already exists. Show that it is configured.

    Check your result

    flatpak remotes lists lab-remote with the option system. Running the add command twice does not error.

    Hint

    flatpak remote-add --if-not-exists NAME URL. Without --user, flatpak writes to the system installation and needs root.

    Solution
    sudo flatpak remote-add --if-not-exists lab-remote https://dl.flathub.org/repo/flathub.flatpakrepo
    flatpak remotes
  3. Practice

    Install, list and run an application

    Search the remote for the Calculator application, install the one whose application ID is org.gnome.Calculator for all users, confirm it is installed, and show its details. (On a server without a desktop, skip the run step and read flatpak info.)

    Check your result

    flatpak list includes org.gnome.Calculator. flatpak info org.gnome.Calculator shows ID, Ref, Origin: lab-remote and Installation: system.

    Hint

    flatpak search calculator, sudo flatpak install -y lab-remote org.gnome.Calculator, flatpak list, flatpak run APPID.

    Solution
    flatpak search calculator | head
    sudo flatpak install -y lab-remote org.gnome.Calculator
    flatpak list
    flatpak info org.gnome.Calculator
  4. Practice

    Update and remove

    Update all Flatpak applications, then uninstall the calculator, remove its unused runtimes, and delete the remote. Confirm nothing is left.

    Check your result

    After the steps flatpak list is empty (or shows only other apps) and flatpak remotes no longer lists lab-remote.

    Hint

    sudo flatpak update -y, sudo flatpak uninstall -y APPID, sudo flatpak uninstall -y --unused, sudo flatpak remote-delete lab-remote.

    Solution
    sudo flatpak update -y
    sudo flatpak uninstall -y org.gnome.Calculator
    sudo flatpak uninstall -y --unused
    sudo flatpak remote-delete lab-remote
    flatpak list
    flatpak remotes
  5. Challenge

    A remote with no internet

    You are told the exam machine has no internet but an administrator has published a Flatpak repository at http://repo.example.com/flatpak that is not signed. Describe the commands to add it as a system remote named internal, install an application from it, and say which option disables signature checks and why you should only use it for a repository you control. Then show how to confirm which remote an installed application came from.

    Check your result

    The add command uses --no-gpg-verify and the URL. flatpak list --columns=application,origin shows internal as the origin.

    Hint

    sudo flatpak remote-add --if-not-exists --no-gpg-verify internal http://repo.example.com/flatpak. Origin is a column of flatpak list.

    Solution
    sudo flatpak remote-add --if-not-exists --no-gpg-verify internal http://repo.example.com/flatpak
    flatpak remotes
    sudo flatpak install -y internal APPLICATION-ID
    flatpak list --columns=application,origin