How to Install Flatpak on Ubuntu 22.04 or 20.04

In recent years, the Linux community has seen an increase in the popularity of containerized software packaging formats, specifically Flatpak and Snap. These formats offer a range of benefits to developers, system administrators, and end-users alike, including increased flexibility, security, and ease of deployment. However, Flatpak has gained more traction among the two formats, especially in the open-source community.

Flatpak, developed by the GNOME project, is an open-source software deployment and package management tool that allows developers to package applications with all their dependencies, making them easily installable and portable across multiple Linux distributions. Flatpak uses a sandboxed environment, ensuring that applications run securely and are isolated from the host system, making it an ideal choice for containerizing software.

On the other hand, Snap is a similar containerized software packaging format developed by Canonical, the company behind Ubuntu. Like Flatpak, Snap also provides isolation, enabling software to run securely on multiple Linux distributions. However, it has been criticized for being tightly controlled by Canonical, limiting its flexibility.

Flatpak is entirely open-source and community-driven, making it more flexible and customizable. It allows developers to distribute software on multiple channels, including a community repository, developer repository, and third-party repositories. This flexibility has led to its widespread adoption in the open-source community.

Moreover, Flatpak has a broader support base than Snap. Major Linux distributions, like Fedora, Debian, and Arch Linux, have Flatpak support enabled by default, while Snap is still less supported. As a result, Flatpak has become the containerization format of choice for many developers and users.

To install Flatpak on Ubuntu 22.04 Jammy Jellyfish or Ubuntu 20.04 Focal Fossa, you can use either Ubuntu’s default repository or the official Flatpak LaunchPAD PPA. Here is a brief guide on installing Flatpak on Ubuntu using these two methods.

Update Ubuntu

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 with Ubuntu 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, which the parent company of Ubuntu owns.

Recently, Canonical has been putting more pressure on using Snap over APT, especially against Flatpak. As a result, Flatpak may be removed altogether in future releases. Therefore, it is recommended to use the Flatpak PPA for the latest versions.

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

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 search and install applications from the Flathub repository easily.

Method 2: Install Flatpak with LaunchPAD 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, the parent company of Ubuntu, has been putting more pressure on using Snap over APT, especially against Flatpak.

Before proceeding with the installation, you need to install some required packages. To do this, run the following command in a Linux terminal:

sudo apt install ca-certificates apt-transport-https software-properties-common lsb-release -y

If you have not previously imported a GPG key from the Ubuntu keyserver, you may encounter issues importing GPG keys from LaunchPAD PPAs via the command line terminal. This is because the necessary directories may not have been created. To fix this, run the following command:

sudo gpg --list-keys

Example output:

gpg: directory '/root/.gnupg' created
gpg: keybox '/root/.gnupg/pubring.kbx' created
gpg: /root/.gnupg/trustdb.gpg: trustdb created

The next step is to import the required GPG key by running the following command:

sudo gpg --no-default-keyring --keyring /usr/share/keyrings/flatpak.gpg --keyserver keyserver.ubuntu.com --recv-keys B8B9D41229DFA5F5

Example output:

 keybox '/usr/share/keyrings/flatpak.gpg' created
gpg: key B8B9D41229DFA5F5: public key "Launchpad PPA for Flatpak" imported
gpg: Total number processed: 1
gpg:               imported: 1

Now that the GPG key has been successfully imported, you can import the stable or development branch of the Flatpak PPA using one of the following commands:

Option 1: Import Flatpak stable PPA for Ubuntu:

echo "deb [signed-by=/usr/share/keyrings/flatpak.gpg] https://ppa.launchpadcontent.net/flatpak/stable/ubuntu $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/flatpak.list

Option 2: Import Flatpak development PPA for Ubuntu:

echo "deb [signed-by=/usr/share/keyrings/flatpak.gpg] https://ppa.launchpadcontent.net/flatpak/development/ubuntu $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/flatpak.list

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 search and install applications from the Flathub repository easily.

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

Example output with Flatpak repository versions listed and which is installed:

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.

Flatpak Commands

This section will explain how to use Flatpak on your Ubuntu system in more detail. Flatpak is a powerful tool for managing and deploying applications on Linux systems, and here are some essential Flatpak commands that can help you use Flatpak effectively.

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 give GIMP permission 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 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

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 to help you manage and deploy applications on your Ubuntu system.

Conclusion

In conclusion, installing Flatpak on Ubuntu is a simple process that can greatly expand the range of applications available on your system. Whether you choose to use the Ubuntu repository or the Flatpak LaunchPAD PPA, the steps involved are straightforward and can be completed quickly from the command line.

Using Flatpak, you can take advantage of its benefits, including easy installation, sandboxing, and a centralized repository for applications. Whether you are a developer looking for a more efficient way to distribute your software or a user looking to easily access a wider range of applications, Flatpak is a powerful tool that can enhance your Ubuntu experience.

FAQs on Flatpak with Ubuntu

Q: What is Flatpak, and how does it differ from traditional package management on Ubuntu?

A: Flatpak is a package management system that allows for installing and distributing Linux applications. Unlike traditional package management on Ubuntu, which relies on the APT package manager, Flatpak uses a containerized approach that allows applications to run in a sandboxed environment, isolating them from the rest of the system. This can help prevent conflicts with other packages and make it easier to manage dependencies.

Q: Can I install Flatpak applications alongside traditional APT-based applications on Ubuntu?

A: Yes, you can install Flatpak applications alongside traditional APT-based applications on Ubuntu. Flatpak applications are installed in a separate directory, and their dependencies are sandboxed. This means that they should not conflict with traditional APT-based applications or cause any system issues.

Q: What are the benefits of using Flatpak on Ubuntu, and why should I consider using it?

A: Flatpak offers several benefits over traditional package management on Ubuntu. These include sandboxing applications to prevent conflicts with other packages, simplified dependency management, and a centralized repository for applications. Flatpak also allows for the easy distribution of applications, making it a popular choice among developers.

Q: Are there any performance or compatibility issues to be aware of when using Flatpak on Ubuntu?

A: Flatpak should not cause any performance or compatibility issues on Ubuntu. Flatpak applications are sandboxed, which can help prevent conflicts with other packages and make it easier to manage dependencies. However, it is important to remember that some applications may require specific system libraries or dependencies, which may not be available in the Flatpak repository.

Q: What is the difference between Flatpak and Snap, and which is better suited for my needs on Ubuntu?

A: Both Flatpak and Snap are package management systems that allow for the installation and distribution of Linux applications. However, they differ in their approach to sandboxing and dependency management. Flatpak uses a containerized approach to sandbox applications, while Snap uses a more traditional approach. Which one suits your needs on Ubuntu will depend on your specific use case and requirements.

Q: How do I update Flatpak applications on Ubuntu, and is it a different process than updating traditional APT-based applications?

A: Updating Flatpak applications on Ubuntu is a simple process that can be done using the Flatpak command line tool. The process is similar to updating traditional APT-based applications, but the commands differ. To update Flatpak applications, you can use the “flatpak update” command in a Linux terminal.

Q: Can I develop and distribute my applications using Flatpak on Ubuntu, and how do I get started?

A: Yes, you can develop and distribute your own applications using Flatpak on Ubuntu. To get started, you must create a Flatpak manifest file describing your application and its dependencies. You can then use the Flatpak command line tool to build and distribute your application.

Q: Are there any security concerns to be aware of when using Flatpak on Ubuntu, and how does it handle sandboxing?

A: Flatpak uses sandboxing to isolate applications from the rest of the system, which can help prevent security issues. However, it is still important to know potential security concerns when using Flatpak on Ubuntu. Installing applications from trusted sources and keeping your system up-to-date with security patches is recommended only.

Q: What is the future of Flatpak on Ubuntu, and are there any plans to integrate it more fully into the system?

A: While Canonical, the parent company of Ubuntu, has been pushing for the use of Snap over APT and Flatpak, the future of Flatpak on Ubuntu remains uncertain. However, it is important to note that Flatpak remains a popular choice among other Linux distributions and the broader Linux community.

In addition, the Flatpak team provides support for a PPA with the latest versions, ensuring that even if Flatpak is removed entirely from Ubuntu, users will still have the ability to install and keep it up-to-date on their system easily. As such, the future of Flatpak on Ubuntu may depend on the continued support and adoption from the Linux community and the availability of the latest versions through the Flatpak PPA.

Share to...