Debian

How to Use apt to Install Programs from Command Line in Debian 11

apt is a package manager tool pre-installed in all Linux-based systems such as Debian. It is used to update, install, remove, or manage packages from the local Linux system repository.  Any program or package which is installed with the apt command runs more efficiently on the respective Linux distribution than the packages installed through other sources, such as snap.

This article is a guide to installing programs using apt from the command line specifically on Debian11 but is applicable to other Linux distributions too.

Use apt to Install Programs from Command Line in Debian 11

The content of this article discusses the usage of the apt command distributed under the following headings:

1: To Install Package from Repository

To install any package from the official Linux repository the apt command can be used by following the below-written syntax:

sudo apt install <Package/Program name>

 

For example;

sudo apt install nodejs

 

2: To Install Package Using Deb File

Many times, it happens that the latest versions of programs/packages are not available in the official Debian repository, in such a case to install the new versions users opt for .deb files of the respective program/package. apt is used to install the packages from the .deb files and for this purpose, follow the below-written syntax:

sudo apt install ./<filename.deb>

 

For example;

sudo apt install ./teamviewer_amd64.deb

 

Note: To install programs/packages from the .deb file, users are required to download the .deb file of that package/program first.

3: To Update Repository

The apt package manager is also used to update the local repository of the system. Basically, the etc/apt/sources.list contains the information of all the available packages/programs inside the repository. So, by running the apt update command, the information/details about the latest versions of all the available programs/packages and their dependencies are displayed. This below-written update command is generally run before installing any package from the repository:

sudo apt update

 

4: To Add PPA Repository

Debian also allows its users to install the programs from the external PPA repositories but for that, the repository needs to be added first. To add a new PPA repository in Debian, the apt command is used by following the below-written syntax:

sudo add-apt-repository ppa:<repository name>

 

For example:

sudo add-apt-repository ppa:jonathonf/nimlang

 

After that, the user can install a package from the PPA repository using the following command:

sudo apt install <package_name>

 

Conclusion

There are multiple ways to install a program in Debian through apt. If a user wants to install the package from an external repository, he/she can use the “apt install” command followed by the package name. However, if a user has downloaded the deb file of a package, they can install the file as well using the “apt install” command. The user can also add a PPA repository using the “add-apt” command to install the latest version of a package on Debian.

About the author

Zahra Zamir

An Electronics graduate who loves to learn and share the knowledge, my passion for my field has helped me grasp complex electronics concepts and now I am here to share them with others.