If you are a Linux user, you might be well aware of the apt-get command. It is a powerful package management tool that can be used to search, install, update, upgrade, and manage the packages in a Linux operating system. It is command-line based tool that is preferred by most system administrators and users.

This article shows how to use the apt-get command for installing programs from the command line in Debian OS.

We have used Debian 10 OS for running the commands and procedure mentioned in this article.

Using apt for installing programs

We will take the example of VLC player for installation using the apt-get command in the command line Terminal application. To open the Terminal, go to the Activities tab on the top left corner of the desktop. Then in the search bar, type terminal. When the Terminal icon appears, click on it to open.

Before installing the software, make sure you have the required software in the repositories of your OS. If it is not already present, you will have to add the additional repository to your sources.list.

Step 1: Add repository

Follow the below steps in order to add the repository to your system.

Enter the following command in Terminal to edit the “sources.list” file.

$ sudo nano /etc/apt/sources.list

Now add the entries in the file using the following syntax:

deb http://site.example.com/debian distribution component1 deb-src

deb-src http://site.example.com/debian distribution component1

For instance, in order to add the repository for VLC player, we have added the following entries:

deb http://deb.debian.org/debian/ unstable main contrib non-free

deb-src http://deb.debian.org/debian/ unstable main contrib non-free

Once done, press Ctrl+O to save and Ctrl+X to exit the nano editor.

Step 2: Update sources

Now after adding the repository, you will need to update your package list. To do so, enter the following command in Terminal:

$ sudo apt-get update

When prompted for the password, enter the sudo password.

Step 3: Install package using apt-get

Now you can install the package from the updated repository. Use the following syntax in Terminal in order to install the packages using apt-get command:

$ sudo apt-get install package-name-1 package-name-2 package-name-3

You can use the above command to install just one package or multiple packages at once. Replace the package-name with your desired package name. If you do not remember the exact package name, just type initial letters and press tab to auto-complete them.

For instance, to install VLC player, the command would be:

$ sudo apt-get install vlc

Step 4: Verify installation

You can verify if the application is installed by viewing it in the list of all installed packages. To do so, run the following command in Terminal:

$ sudo dpkg--list

After installation, you can launch the application via Terminal or via system application’s menu.

Upgrade packages

You can also upgrade the packages to their latest available versions using the apt-get command.

Use the following command syntax in order to upgrade the packages:

$ sudo apt-get upgrade package-name-1 package-name-2 package-name-3

To upgrade all packages, you can use the following syntax:

$ sudo apt-get upgrade

Remove packages

In case you want to remove the installed packages using the apt-get command, you can do so by using the following syntax:

$ sudo apt-get remove vlc

The system will provide you with Y/n option to confirm the removal process. Press y to continue and the package will be removed from the system. However, note that this will only remove the package but not the configuration files. In order to remove the configuration files too, use the following command:

$ sudo apt-get purge package_name

In this article, we have learned the use of apt-get command for installing packages in a Debian system. Using the command line for installing and managing packages saves a lot of time. It also comes in handy when you are accessing and performing the installation on a remote system via SSH.

How to use apt to install programs from command line in Debian

Karim Buzdar

About the Author: Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. He blogs at LinuxWays.