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:
- How to update system packages using apt-get command
- How to upgrade system packages using apt-get command
- How to install brand new packages on the system using apt-get command
- How to remove installed packages from system using apt-get command
- How to clean the system using apt-get command
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:
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:
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:
Set name_of_package according to your requirement.
To upgrade package “python3” run below mentioned command:
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:
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:
Now to install node js using apt-get run the below mentioned command:
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:
To install NodeJS and npm together run the below mentioned command:
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:
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:
Another command is used to remove package from system using “apt-get”, below mentioned is its syntax:
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:
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:
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:
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”:
To know more about apt-get command run the man command as mentioned below:
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).