How to use apt to install programs from the command line on Debian

If you are a Linux user, you may be familiar with the apt-get command. It is a powerful package management tool that you can use to find, install, update, upgrade, and manage packages on the Linux operating system. It is a command line based tool preferred by most sysadmins and users.

This article explains how to use the apt-get command to install programs from the command line on Debian OS.

We used Debian 10 OS to execute the commands and procedures mentioned in this article.

Using apt to install programs

We will take an example VLC player to install using the apt-get command in the Terminal application command line. To open Terminal, go to the Actions tab in the upper left corner of your desktop. Then enter terminal in the search bar. When the terminal icon appears, click it to open it.

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

Step 1. Add the repository

Follow the steps below 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 entries to the file using the following syntax:

                      deb distribution component1 deb-src

deb-src distribution component1

For example, to add the repository for the VLC player, we added the following entries:

                      deb unstable main contrib non-free

deb-src unstable main contrib non-free

After that press Ctrl + O to save and Ctrl + X to exit nano editor.

Step 2. Update sources

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

                      $ sudo apt-get update

When prompted for a password, enter your sudo password.


Step 3. Install the package using apt-get

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

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

You can use the above command to install only one package or multiple packages at a time. Replace the package name with the desired package name. If you don’t remember the exact name of the package, just enter the initial letters and press the Tab key to fill them in automatically.

For example, to install the VLC player, the command would look like this:

                      $ sudo apt-get install vlc

Step 4. Verify the installation

You can check if the application is installed by looking at it in the list of all installed packages. To do this, run the following command in the Terminal:

                      $ sudo dpkg--list

After installation, you can launch the application through the Terminal or through the system application menu.

Service packs

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

Use the following command syntax to update packages:

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

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

                      $ sudo apt-get upgrade

Remove packages

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

                      $ sudo apt-get remove vlc

The system will provide you Well no the ability to confirm the deletion process. Click at to continue and the package will be removed from the system. Note, however, that this will only remove the package and not the configuration files. To remove and configure files, use the following command:

                      $ sudo apt-get purge package_name

In this article, we have learned how to use the apt-get command to install packages on a Debian system. Using the command line to install and manage packages saves a lot of time. It also comes in handy when you access and install on a remote system via SSH.

How to use apt to install programs from the command line on Debian

Related Posts