An apt-get command is a powerful tool that allows you to handle packages in a Linux system. apt-get command’s main task is to retrieve information and packages to authenticate for installation, upgradation, and removal of packages.
The apt-get command is quite similar to the apt command with a similar command structure and serves almost the same purpose. However, there are some key differences between them and in this article, we are going to learn how to use the apt-get command and see its main differences from the apt command.
Also read: apt command in Linux [Complete Guide]
apt vs apt-get
Both apt and apt-get commands aim to put all necessary tools in one place for managing packages in a Linux system. However, their major differences lie in the way the data is presented to the end user. The apt command has traditionally been the more intuitive of the commands, providing users with helpful progress bars, and are often easier to use.
However, the apt-get command offers an array of different features that you can not get using the apt command. The apt and apt-get commands are also not backward compatible meaning although some of the syntaxes may be similar, the syntax for one may not always work on another. So, for any power user, it is worth spending some time grasping the basic commands of the apt-get command.
How to Use apt-get Command in Linux
Below is a detailed syntax for the apt-get command in Linux. We included helpful images to guide you along the way. We also included common tasks you can perform using the apt-get command like installing or removing packages.
Syntax
or
or
Installing packages using the apt-get command
Installing packages is fairly simple using the apt-get command. The syntax for it is as follows:
You have to replace the package name with the software you want to install. If you are unsure about the exact name, you can either search on the web or press the first few letters and press the tab button. Here is an example of installing a text editor in Linux.
You can also install the specific version of the software by using the following syntax.
Here is an example of installing version 7.1 of the nano text editor in Linux.
Once you run the apt-get install command you will be prompted with a confirmation of whether you want to install the packages, press “Y” followed by enter to proceed with the installation.
You can also install multiple packages using a single command by using the following syntax.
In the example above, we used one apt-get command to install both vim and nano (text editors) in the system.
You can also use the –download-only command to only download the packages but not install them.
How to Remove Packages with apt-get
Removing packages works the same way, you initiate removal using the following command.
If you also want to remove all other configuration files that the package may leave behind, use the following command.
How to Update Using the apt-get command
It is essential to resynchronize the package index files and update the package repository before installing a package. By doing this, you can be confident the packages you install are current.
You can also check for broken dependencies using the following command:
To upgrade all current packages use the following apt-get command:
However, if you want to update a specific package instead of all packages, simply type the name of the package you want to upgrade.
Advance apt-get commands in Linux
Apt-get command also offers an array of other useful options, some of the most used ones are as follows:
Conclusion
The apt-get command in Linux is easy to remember and hardly requires any technical skills to implement. It is useful for managing packages and is a great alternative to the apt command we saw earlier.