How to Install Flatpak on Ubuntu 24.04, 22.04 or 20.04

Flatpak is a popular framework for distributing and running applications in a secure, sandboxed environment on Linux systems. It allows you to install and run applications regardless of the Linux distribution you use, providing consistency and security across different environments. Flatpak packages include all the necessary dependencies, ensuring that applications run as expected without conflicting with system libraries. It’s particularly useful for accessing the latest versions of software that might not be available through traditional package managers.

On Ubuntu 24.04, 22.04, or 20.04, you can install Flatpak via two methods: using the default Ubuntu repository for a stable and straightforward installation, or adding the Flatpak Team Launchpad PPA for access to the latest stable release or development builds for those who want to contribute to testing. This guide will walk you through both methods, ensuring you have the latest Flatpak setup that suits your needs.

Update Ubuntu Before Flatpak Installation

The first task is to update your system to ensure all existing packages are up to date before installing.

sudo apt update && sudo apt upgrade

Method 1: Install Flatpak via Default APT Repository

Installing Flatpak on Ubuntu can be done through different methods. The first method we will discuss is installing it using the Ubuntu repository. It is important to note that by default, Ubuntu keeps Flatpak in its repository. Still, it is not installed by default due to its competition with Snap, the parent company of Ubuntu.

To install Flatpak using the Ubuntu repository, you can use the following command in a Linux terminal:

sudo apt install flatpak

This command prompts you to enter your root password before installing Flatpak. After you enter your password, the installation process will begin.

Once installed, you can add the Flathub repository, which is the primary repository for Flatpak applications, by running the following command:

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

This command will add the Flathub repository to your Flatpak installation, allowing you to easily search for and install applications from the Flathub repository.

Method 2: Install Flatpak via Flatpak Team APT PPA

The second method of installing Flatpak on Ubuntu uses the “Flatpak” team LaunchPAD PPA, which contains the latest stable and development versions of Flatpak. This method is highly recommended as Canonical, Ubuntu’s parent company, has been putting more pressure on using Snap over APT, especially against Flatpak.

Option 1: Import Flatpak stable PPA:

sudo add-apt-repository ppa:flatpak/stable -y

Option 2: Import Flatpak development PPA:

sudo add-apt-repository ppa:flatpak/development -y

After importing the PPA, run an APT update to ensure that the changes are reflected:

sudo apt update

Now, install Flatpak by running the following command:

sudo apt install flatpak

This command will prompt you to enter your root password before installing Flatpak. After entering your password, the installation process will begin.

Once installed, you can add the Flathub repository, which is the primary repository for Flatpak applications, by running the following command:

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

This command will add the Flathub repository to your Flatpak installation, allowing you to easily search for and install applications from the Flathub repository.

Furthermore, once you have installed the Flatpak version using the PPA, you can check the installed version by using the “apt-cache policy” command, as shown below:

apt-cache policy flatpak

As shown in the guide, the installation process installed the development version of Flatpak, which was version 1.15.3 at the time of writing. It is important to note that this version may be slightly ahead of the Flatpak PPA stable version and significantly ahead of Ubuntu’s default version, which is 1.12.7 and considered outdated.

Basic Flatpak Commands

This section will explain how to use Flatpak on your Ubuntu system in more detail.

Adding a Remote Repository

Flatpak uses remote repositories to download and install applications. To add a remote repository, use the following command:

flatpak remote-add --if-not-exists <name> <URL>

For example, to add the Flathub repository, which is the primary repository for Flatpak applications, use the following command:

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

Installing Applications

To install an application using Flatpak, use the following command:

flatpak install <application-name>

For example, to install the GIMP image editing software, use the following command:

flatpak install org.gimp.GIMP

Updating Applications

To update an application that was installed using Flatpak, use the following command:

flatpak update <application-name>

For example, to update GIMP, use the following command:

flatpak update org.gimp.GIMP

Uninstalling Applications

To uninstall an application that was installed using Flatpak, use the following command:

flatpak uninstall <application-name>

For example, to uninstall GIMP, use the following command:

flatpak uninstall org.gimp.GIMP

Listing Installed Applications

To list all the applications that were installed using Flatpak, use the following command:

flatpak list

Searching for Applications

To search for an application in the Flatpak repository, use the following command:

flatpak search <search-term>

For example, to search for the LibreOffice productivity suite, use the following command:

flatpak search libreoffice

Listing Remote Repositories

To list all the remote repositories that are currently configured, use the following command:

flatpak remote-list

Checking for Updates

To check for updates to applications installed using Flatpak, use the following command:

flatpak update

Updating the Flatpak System

To update the Flatpak system itself, use the following command:

flatpak update --system

Info on Applications

To get information about an application, such as its version and other details, use the following command:

flatpak info <application-name>

For example, to get information about GIMP, use the following command:

flatpak info org.gimp.GIMP

Running Applications

To run an application that was installed using Flatpak, use the following command:

flatpak run <application-name>

For example, to run GIMP, use the following command:

flatpak run org.gimp.GIMP

Sideload an Application

To sideload an application that was not downloaded from a repository, use the following command:

flatpak install <path-to-application>

Exporting an Application

To export an application that was installed using Flatpak to a file, use the following command:

flatpak export <application-name

Exporting an Application

To export an application that was installed using Flatpak to a file, use the following command:

flatpak export <application-name> <filename>

For example, to export GIMP to a file called gimp.flatpak, use the following command:

flatpak export org.gimp.GIMP gimp.flatpak

Importing an Application

To import an application that was exported using Flatpak, use the following command:

flatpak install <filename>

For example, to import the gimp.flatpak file that was exported earlier, use the following command:

flatpak install gimp.flatpak

List Files in an Application

To list the files that were installed as part of an application, use the following command:

flatpak list-files <application-name>

For example, to list the files installed as part of GIMP, use the following command:

flatpak list-files org.gimp.GIMP

Check Application Permissions

To check the permissions that an application has, use the following command:

flatpak permissions <application-name>

For example, to check the permissions for GIMP, use the following command:

flatpak permissions org.gimp.GIMP

Change Application Permissions

To change the permissions that an application has, use the following command:

flatpak override <application-name> --filesystem=<directory>

For example, to permit GIMP to access a directory called MyPhotos, use the following command:

flatpak override org.gimp.GIMP --filesystem=/home/user/MyPhotos

Remote Update

To update all remote repositories, use the following command:

flatpak update --appstream

Update a Single Remote

To update a single remote repository, use the following command:

flatpak update <remote-name>

Remove a Remote

To remove a remote repository, use the following command:

flatpak remote-delete <remote-name>

Run Application in Sandbox

To run an application in a sandbox environment, use the following command:

flatpak run --sandbox <application-name>

For example, to run GIMP in a sandbox environment, use the following command:

flatpak run --sandbox org.gimp.GIMP

Create an Application Bundle

To create an application bundle that can be distributed and installed on other systems, use the following command:

flatpak build-bundle <directory> <bundle-file>

For example, to create a bundle for GIMP, use the following command:

flatpak build-bundle org.gimp.GIMP gimp.bundle

List Installed Runtimes with Flatpak on Ubuntu

To list all the runtimes that are currently installed, use the following command:

flatpak list-runtime

List Available Runtimes

To list all the runtimes that are available in the repository, use the following command:

flatpak list-runtime -a

List Extensions

To list all the extensions that are currently installed, use the following command:

flatpak list-extension

List Available Extensions

To list all the extensions that are available in the repository, use the following command:

flatpak list-extension -a

These are just some of the essential Flatpak commands for managing and deploying applications on your Ubuntu system.

Conclusion

With Flatpak installed on your Ubuntu system, you have access to a vast range of applications that are securely sandboxed and consistently updated across distributions. Whether you choose the stability of the default Ubuntu repository or the cutting-edge features from the Flatpak Team Launchpad PPA, you’ll ensure that your system is equipped to handle the latest applications available through Flatpak. Regular updates, especially when using the PPA, will keep your Flatpak installation current and ready for all the latest software. Enjoy the flexibility and security that Flatpak brings to your Ubuntu environment.

Leave a Comment