Debian

How to use apt-get command on Debian 11

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:

$ sudo apt-get update

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:

$ sudo apt-get upgrade

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

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

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

$ sudo apt-get install nodejs

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

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

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:

$ sudo apt-get purge npm

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:

$ sudo apt-get clean

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:

$ sudo apt-get autoclean

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

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

$ man apt-get

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

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.