Debian

How to Install and Use Flatpak on Debian 12

Flatpak is an independent package manager that allows you to install applications on your system. It comes with its own neatly package suitcase that contains everything an application needs to run flawlessly on your system. The applications installed through Flatpak don’t require any dependencies nor do they conflict with your system packages. Each application installed through Flatpak is isolated and works on almost all Linux operating systems including Debian 12.

In this guide, you will learn:

How to Install Flatpak on Debian 12

You can install Flatpak on Debian 12 directly from the official system repository using the following command:

sudo apt install flatpak -y

How to Install Package from Flatpak on Debian 12

After installing Flatpak, you must add a Flathub remote repository so that you will be able to install packages from Flatpak on Debian 12. You can do this using the following command:

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

You can verify the Flatpak remote repository is successfully added to the Debian using the following command:

flatpak remotes

After adding repository, search for the Application ID of the package you want to install on Debian through Flatpak using the following syntax:

flatpak search --columns=application application_name

Here, I am installing discord on Debian 12 from Flatpak so replaced application_name with discord to search for its ID:

After finding the Application ID, you can use that ID to install the application on Debian from flatpak using the below-given command:

sudo flatpak install flathub Application ID -y

How to Run Application from Flatpak on Debian 12

You can run the application installed through Flatpak on Debian 12 by using the flatpak run command followed by the Application ID:

flatpak run Application ID

How to List Installed Packages Through Flatpak on Debian 12

To see the list of packages that you install through Flatpak on Debian, you can use the following command:

flatpak list

How to Update Flatpak on Debian 12

In case you want to update Flatpak on Debian, simply run the following command that will check for updates and install them automatically on your system:

flatpak update

How to Repair Flatpak on Debian 12

In case you encounter any issue while working with Flatpak on Debian, you can run the below-given command to fix it:

flatpak repair

How to Remove a Package from Flatpak on Debian 12

You can remove a package from Flatpak on Debian 12 using the flatpak remove command with sudo privileges followed by the Application ID, as given below:

sudo flatpak remove com.discordapp.Discord

How to Build a Flatpak Application on Debian 12

Besides using Flatpak to install an application, you can also use it to build an application on your Debian system, this can be done using following steps:

Step 1: Install Runtime and Matching SDK

For building a Flatpak application, you should install a runtime and a matching SDK from the following command, as they will be used to build apps at run time:

flatpak install flathub org.freedesktop.Platform//23.08 org.freedesktop.Sdk//23.08 -y

Step 2: Install Flatpak Builder on Debian

You must also require installing Flatpak builder on your Debian system that is used for building the packages, it can be installed from the following command:

sudo apt install flatpak-builder -y

You should also install the flatpak-builder package from Flatpak as well using the following command:

sudo flatpak install flathub org.flatpak.Builder -y

Step 3: Create a Script

Here, as an example, I am creating a simple script hello.sh that will run as an app and display the value on the terminal.

To create a script on Debian 12, you can use the following command:

sudo nano hello.sh

Inside the script, I have added the following lines:

#!/bin/sh

echo "Hello Linux Hint Users"

Then save the script using CTRL+X, add Y and press Enter to exit.

Step 4: Add Manifest to an App

You should also require adding a manifest to the app you are going to create; this can be done by adding the following information in an empty file. This manifest file provides the basic information about your application and some instructions on how to use the application for building process.

id: org.flatpak.Hello

runtime: org.freedesktop.Platform

runtime-version: '23.08'

sdk: org.freedesktop.Sdk

command: hello.sh

modules:

- name: hello

buildsystem: simple

build-commands:

- install -D hello.sh /app/bin/hello.sh

sources:

- type: file

path: hello.sh

Note: Don’t forget to save the file. Further, you can modify the script according to your needs and application name.

Step 5: Build the Application

After creating the manifest file, you can build it using the flatpak-builder command followed by the target directory and the manifest file name:

flatpak-builder build-dir org.flatpak.Hello.yml

Step 6: Run the Application

You can now run the application using the flatpak run command followed by the application name you have created:

flatpak run org.flatpak.Hello

This ensures that we have successfully build an application on Debian 12 from Flatpak.

Conclusion

Flatpak is a useful package manager that can be installed on Debian 12 from the system repository. You can use this package manager to install applications on your system and they will run flawlessly without any compatibility issues. This guide has provided a brief overview of how you can install Flatpak on Debian 12 and use it to install and run applications on your system. You will also find a guide on how you can list and remove packages from Flatpak in case you don’t need them. Besides that, you will also learn building your first Flatpak application on your Debian system from this guide.

About the author

Awais Khan

I'm an Engineer and an academic researcher by profession. My interest for Raspberry Pi, embedded systems and blogging has brought me here to share my knowledge with others.