The apt-get command is a common and useful Linux command. Linux OS users have definitely used the “apt-get” command. If you are new to Linux, then you must know the usage of this command. The “apt-get” command is the Advanced Package Tool (APT) that handles software installation and removing. In this Article, several uses of apt-get commands on Debian 11(Linux OS) will be discussed in detail which will be very helpful for both beginners and users of the Debian system.

The apt and apt-get commands are used for management of packages, the difference is that all the functions performed by apt-get, apt-cache and apt-config commands are solely performed by apt command so this is also the reason that apt command is now getting popular day by day.

The uses of apt-get command which will be explained further in detail in this Article are:

Requirement

Super user permissions are required for the “apt-get” command.

Each use of apt-get command is explained in detail below:

How to update system packages using apt-get command

The apt-get relies on a database of existing packages to function. If you don’t keep this database up to date, the system probably doesn’t know if newer packages are available. Also after installing Debian system you first need to update your system using apt-get:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/10/echo/How-to-use-apt-get-command-on-Debian-11-1.png" data-lazy- height="283" src="data:image/svg xml,” width=”976″>

After running this command, you’ll see different keywords before packages which give some information about package:

Hit: Indicated that the version of the package has not changed.

How to upgrade system packages using apt-get command

Update command is only used to upgrade the packages, so to upgrade all packages in Debian 11 system, run the below mentioned command:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/10/echo/How-to-use-apt-get-command-on-Debian-11-2.png" data-lazy- height="253" src="data:image/svg xml,” width=”978″>

The above output shows that all the packages on my system are already up to date. To upgrade particular package use the below mentioned syntax:

$ sudo apt-get upgrade [name_of_package]

Set name_of_package according to your requirement.

To upgrade package “python3” run below mentioned command:

$ sudo apt-get upgrade python3

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/10/echo/How-to-use-apt-get-command-on-Debian-11-3.png" data-lazy- height="324" src="data:image/svg xml,” width=”980″>

Though on my system Python3 is already on the latest version.

How to install brand new packages on system using apt-get command

Installation of a new package from Debian 11 repository can be done using apt-get command; the name of the package you want to install should be known prior.

Installing single package at a time: To install single package at a time with apt-get command, use the below mentioned syntax:

$ sudo apt-get install [name_of_package]

Set name_of_package according to your requirement. The best thing about using this command is that you don’t need to remember the full command name and just type few words and press tab key once, it will display all packages with these words like to check all possibilities with “node” type below mentioned command and press Tab:

$ sudo apt-get install node

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/10/echo/How-to-use-apt-get-command-on-Debian-11-4.png" data-lazy- height="632" src="data:image/svg xml,” width=”976″>

Now to install node js using apt-get run the below mentioned command:

$ sudo apt-get install nodejs

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/10/echo/How-to-use-apt-get-command-on-Debian-11-5.png" data-lazy- height="628" src="data:image/svg xml,” width=”981″>

Get: It tells that a new package is available. The information of the package will be downloaded by apt-get but not the package as you can see above.

Installing multiple packages at a time : To install multiple packages at a time with apt-get command, use the below mentioned syntax:

$ sudo apt-get install [package-name1] [ package-name2]

To install NodeJS and npm together run the below mentioned command:

$ sudo apt-get install nodejs npm

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/10/echo/How-to-use-apt-get-command-on-Debian-11-6.png" data-lazy- height="675" src="data:image/svg xml,” width=”977″>

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/10/echo/How-to-use-apt-get-command-on-Debian-11-7.png" data-lazy- height="675" src="data:image/svg xml,” width=”978″>

How to remove installed packages from system using apt-get command

We can not only install but also remove packages with the help of “apt-get” command. To remove particular installed package, use the below mentioned syntax:

$ sudo apt-get remove [package-name]

The “apt-get remove” will only remove binary files of a particular package, not the configuration files.

To remove “nodejs” from system run the below mentioned command:

$ sudo apt-get remove nodejs

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/10/echo/How-to-use-apt-get-command-on-Debian-11-8.png" data-lazy- height="675" src="data:image/svg xml,” width=”977″>

Another command is used to remove package from system using “apt-get”, below mentioned is its syntax:

$ sudo apt-get purge [package-name]

The “apt-get purge” command will remove both binary and configuration files of a particular package.

To completely remove npm from system run the below mentioned command:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/10/echo/How-to-use-apt-get-command-on-Debian-11-9.png" data-lazy- height="586" src="data:image/svg xml,” width=”979″>

How to clean the system using apt-get command

We need to clean our system to free some disk space by removing all garbage packages or files from the system. To clean the system in three different ways using apt-get command:

Using “apt-get clean” command: This command is used to clean all retrieved package files (apt cache) by below mentioned syntax:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/10/echo/How-to-use-apt-get-command-on-Debian-11-10.png" data-lazy- height="153" src="data:image/svg xml,” width=”981″>

Using “apt-get autoclean” command: Like the clean command, apt-get autoclean also deletes the retrieved package files which are newly installed, and will no longer in use:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/10/echo/How-to-use-apt-get-command-on-Debian-11-11.png" data-lazy- height="270" src="data:image/svg xml,” width=”976″>

Using apt-get autoremove command : Another option is to utilize “autoremove” to clear up disc space. It uninstalls packages and libraries that were installed automatically to meet the requirements of another package as they were useless if a particular package is removed.

Run the below mentioned command to clean system using “apt-get autoremove”:

$ sudo apt-get autoremove

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/10/echo/How-to-use-apt-get-command-on-Debian-11-12.png" data-lazy- height="677" src="data:image/svg xml,” width=”977″>

To know more about apt-get command run the man command as mentioned below:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/10/echo/How-to-use-apt-get-command-on-Debian-11-13.png" data-lazy- height="676" src="data:image/svg xml,” width=”979″>

Conclusion

To manage the Debian system in a better way you must be familiar with the “apt-get” command. Some of the uses of the “apt-get“ command discussed in this write up are: updating and upgrading packages, installing/removing packages and cleaning the system using apt-get. This write up will be useful to both new and veteran Debian users (Linux OS).

About the author

<img alt="" data-lazy-src="https://secure.gravatar.com/avatar/7c99efcc024949e17b176845c757687e?s=112&r=g" data-lazy- height="112" src="data:image/svg xml,” width=”112″>

Alishba Iftikhar

I am currently an undergraduate student in my 1st year. I am an internee author with Linuxhint and loved learning the art of technical content writing from senior authors. I am looking forward to opting my career as a full time Linux writer after I graduate.