How to Use apt-get Command?

The apt-get is one of the most common and useful commands every Linux enthusiast uses frequently. You can run this command via the terminal, and there are many benefits that you can take from this command.

This command will not only make your life easier but make you comfortable, as well as you can do most of the work without using the application manager.

In this article, we will be discussing some of the most common uses of this command that will help you a great deal in the long term.

How to Use the apt-get Command?

You can get detailed information regarding the apt-get command by running the command mentioned below. All the information will be displayed in a new window with all the commands you can run using the apt-get command:

$ man apt-get
How to install Kali Linux in Window...

Now, let’s discuss some of the most common commands you can run using the apt-get command.

Update All System Packages Using apt-get Command

The first one on the list is the update command which is used to locate all the packages installed in your Linux operating system (OS). After that, it will do a thorough search and give you information on how many packages are there having older versions that you can update.  You need to write the following command to run this process:

$ sudo apt-get update

Upgrade All System Packages Using apt-get Command

You need to run the following command to upgrade all the packages to their latest version once you run the update command:

$ sudo apt-get upgrade

Upgrade a Specific Application Using apt-get Command

You can also update any specific application using the syntax mentioned below:

$ sudo apt-get upgrade [Application name]

For example, if you want to install the vim editor, you can do that by typing the command mentioned below:

$ sudo apt-get upgrade vim

Upgrade Multiple Applications Using apt-get Command

You can also upgrade multiple applications by writing a single command as follows:

$ sudo apt-get upgrade [App 1] [App 2] . . .

This will upgrade the vim application first, and after that, it will automatically start upgrading the Firefox application.

Upgrade Distributions using apt-get Command

When an upgrade is performed, this command checks for packages dependent on the upgraded package and tries to install new ones or remove existing ones.

$ sudo apt-get dist-upgrade

Installing Applications Using apt-get Command

You can install any application, such as vim editor, using the following command:

$ sudo apt-get install vim

Installing Multiple Applications Using apt-get Command

You can also install multiple applications such as vim editor and Firefox browser using a single command shown below:

$ sudo apt-get install vim firefox

Removing Application Using apt-get Command

If you are planning to remove unnecessary applications that are no longer needed, then you can remove them by typing the following syntax:

$ sudo apt-get remove [App Name]

Suppose you are planning to remove the vim application then you can do that by typing:

$ sudo apt-get remove vim

Purge is another variation of the remove command, but one significant difference is that it will also remove the configuration file as well along with the application. So, you can use it too by removing any application from your system by typing:

$ sudo apt-get purge vim

If you want to remove the dependencies that are no longer needed, then you can remove them by typing:

$ sudo apt-get autoremove

Clear Package Manager Cache using apt-get Command

Sometimes it happens that you are not able to install the application and facing errors while running the command from the terminal. One of the solutions that you can implement in such scenarios is by using a clean command which will remove the cache memory of the package manager. So, to apply this command, you need to follow the syntax below:

$ sudo apt-get clean

That’s all from this guide!

Conclusion

Apt-get is one of the most useful commands that will help you greatly in Linux. You won’t need to run the application manager anymore, as most tasks can be performed using this command. So, if you are a beginner or unaware of this command, you can get all the details from this article. For a detailed explanation, numerous examples are demonstrated to show the usage of the apt-get command.