Debian

How to install packages on Debian 11


Installing packages means making the programs ready to use, in Debian 11 (the latest version of Debian; bullseye) we can install the new package using a tool known as package manager. This tool helps to install, delete, configure or upgrade different packages, these package managers can either be a command-line or can be a GUI (graphical user interface). There were different package managers used in Debian 11 to install packages like apt, snap, gdebi, aptitude, and dpkg, some of them are by default in Debian and others have to be installed.

In this article, we will discuss all the ways of installing the packages in Debian 11 with the help of examples.

Installing a package using apt

Apt (advanced packaging tool) is the default tool of the command-line used to install the different packages, remove, update and upgrade them.

Apt do not install the files with extensions name like .deb, it installs the packages with their primary name like MongoDB, VLC, because apt command updates the /etc/apt/sources.list file and install the packages included in it, so if we want to install any package with the extension like .deb, specify its path using “./” with the name.

The general syntax of using the apt command to install packages is.

$ sudo apt install [package name]

To install the package, let’s say, vlc, use:

$ sudo apt install vlc -y

To install the deb package, for example, Visual Studio Code, use:

$ sudo apt install ./code.deb

We can also use the apt command to remove the unwanted packages from Debian. The general syntax of removing the package is:

$ sudo apt remove [package-name]

To remove a package with its dependencies use:

$ sudo apt autoremove [package-name]

For example, to remove the package VLC we can use an apt statement.

$ sudo apt autoremove vlc

Installing a package using dpkg

Dpkg can also be used to install the packages in Debian 11, not only it is used to install but also for the upgrade, configuration, and removal of the packages. The dpkg is also a default command-line package management interface just like the apt command, but it slightly differs from the apt such as dpkg does not install the dependencies of the package (if needed) but apt can install the dependencies too while installing the package. Similarly, dpkg does not install the packages from remote addresses, it only installs the packages whose installation files are downloaded. It is used mostly to install Debian packages.

The general syntax of the dpkg command to install using any package using i flag (i flag is used to install the package)

$ sudo dpkg -i [package]

For example, we install the package code.deb using the dpkg command:

$ sudo dpkg -i code.deb

The general syntax of removing the unwanted package from the Debian 11 is

$ sudo dpkg -r [package]

For example, we want to remove “code” using the dpkg command.

$ sudo dpkg -r code

If we want to remove the package along with its configuration files, then we can use flag “p”, the general syntax of removing the package along with its configuration file will be

$ sudo dpkg -p [package name]

Installing a package using aptitude

Aptitude is also a command used to install packages, it works similar to the apt command but the difference is that the aptitude command is not available by default in Debian, so we have to install it.

To install aptitude we can run the following command

$ sudo apt install aptitude

The general syntax of installing a package using the aptitude is

$ sudo aptitude install [package name]

The difference between the apt and aptitude is level difference such as aptitude is a higher-level and apt is a lower-level package manager which means apt can be used in higher-level packages. We will install the python3-nacl using the aptitude command.

$ sudo aptitude install python3-nacl

We can see it is showing the progress of the installation:

Aptitude command also has the ability to display and retrieve the changelog of the official packages of Debian. If we want to remove the unwanted package using the aptitude command, the general syntax will be.

$ sudo aptitude remove [package name]

For example, if we want to remove the package python3-nacl, using the aptitude command.

$ sudo aptitude remove python3-nacl

Installing a package using gdebi

In Debian 11, the gdebi utility can also be used to install the packages, it works similar to the apt but the difference is apt installs the dependencies of packages from remote only like HTTPS, whereas the gdebi installs local packages resolving the dependencies of the package. Gdebi is not a default package manager in Debian, so we can install it as:

$ sudo apt install gdebi

To install the package using gdebi, the general syntax will be:

$ sudo gdebi [package name]

For example, we install visual studio using gdebi.

$ sudo gdebi code.deb

However, gdebi has no command to remove the unwanted packages.

Installing a package using flatpak

Sandbox applications can be installed on Debian 11 using the flatpak command. The flatpak is not the default application, we have to install flatpak in Debian 11 to use it. For the installation, first, run the following statement in the terminal to enter the root user mode:

$ sudo -s

Run the following command to install flatpak.

# apt install flatpak

Install the GNOME plugins for the flatpak by command.

# apt install gnome-software-plugin-flatpak

Also, enable the flatpak by adding the repository of flatpak repo from the flathub, so its applications can be installed.

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

Now will install the application of gnome recipes using the flatpak

$ flatpak install --from https://git.gnome.org/browse/recipes/plain/flatpak/gnome-recipes.flatpakref

To run this application.

$ flatpak run org.gnome.Recipes

The output will as:

Conclusion

Some commands have been obsoleted in the newer version of Debian 11 like apt-get, but there are many other commands which can be used as an alternative to apt-get to install the packages in Debian 11. In this article, we have discussed different commands to install packages in detail in Debian 11 like apt, dpkg, gdebi, aptitude, and flatpak. We also explain the general syntax of these commands and explain with the help of examples how these commands are used to install and remove packages from Debian 11.

About the author

Hammad Zahid

I'm an Engineering graduate and my passion for IT has brought me to Linux. Now here I'm learning and sharing my knowledge with the world.