What does sudo apt-get update command do? [Linux Commands List]

When you choose to install a Linux distribution, you have to prepare yourself to know some of the important terminal Linux commands that you can’t escape from. And, one such command is:

sudo apt-get update

You will need to utilize this command if you are using Ubuntu or any other Ubuntu-based distribution or flavors. In my case, I use elementary OS 5 Juno, which is based on Ubuntu. Fret not, the apt-get command is not rocket science, you just need to know what it does to be able to correctly utilize it.

Also, if you understand what it does, you do not have to go search on the Internet repeatedly, it isn’t big command, is it? Just something tiny that does something important!

I’m sure that when we get used to the commands we don’t even bother to know what it actually does – technically (or what does it mean). A few users just copy-paste the command from the forum and get it working. That’s understandable. I’ve been there.

But, after reading this article – you won’t look back to refer what apt-get does and how do you utilize it. So, in this article, we will talk about all the apt-get commands while also mentioning specifically what apt-get update does.

Note: For all the commands mentioned, ignore the symbols <> and replace what’s written inside it with the package name.

What is apt-get?

Answer: apt-get command helps you to manage the packages on your Linux system.

Technically, APT stands for Advanced Package Tool – which points to this as the command for package management. But, this stands true only for Debian derived Linux distribution like Ubuntu because Debian relies ondpkg packaging system to install and manage applications/programs. And, APT command line tool is required to help manage the packages using that package system.

So, yes, if a Linux distro uses a different packaging system – you will not need to utilize apt-get there.

What does sudo apt-get update do?

First of all, it is one of the Linux commands to maintain the packages. It just updates the list of latest updates available for the packages installed on your system. And, it is very important to enter this command before trying to install anything because you will be able to avoid outdated files from the database.

So, basically, you are just refreshing the list of available updates with this command.

To understand the command, we’ll break it down:

sudo – this is mandatory as a prefix for a command if you need root privileges.

apt-get – to manage a package (install/remove/update) you need to start your command with this.

update – unlike what you’d expect, it instructs to fetch the latest list of available packages from the repositories – instead of “updating the packages”.

After you enter the command, you get to manage your packages as per the latest database available to you.

Here’s what happens when you enter the sudo apt-get update command:

Whats does sudo apt-get update command do?

In the screenshot above, “Hit” tells you that there’s no new package version available. “Get” refers to a new version and it refreshes the database. And, “Ign” means that it just ignored the package for some reason.

Common Confusion: Is it sudo apt-get update or sudo apt-get upgrade?

sudo apt-get update command

apt-get update and apt-get upgrade are two different commands. We’ve talked about the first one above, but what does the later do?

sudo apt-get upgrade

Well, apt-get upgrade simply upgrades/installs the new version of the package available over the old one. But, do note that in order to ensure that you are upgrading your packages to the latest version, you will need to type the apt-get update command before it.

How do you upgrade a specific package?

Now we know that apt-get upgrade will let us upgrade our installed packages – but if we don’t want to upgrade all the packages, we can be specific about what we want to upgrade by entering the command with the following format:

sudo apt-get upgrade <insert package name here>

There’s another way of upgrading as well – but it could be a mess because it is a more powerful command:

sudo apt-get dist-upgrade

This command looks for newer dependencies and prioritizes upgrading them by the possibility of removing the old ones – which could be dangerous. So, in order to use it, you need to know what dist-upgrade does, as per the official documentation:

In addition to performing the function of upgrade, this option also intelligently handles changing dependencies with new versions of packages; apt-get has a “smart” conflict resolution system, and it will attempt to upgrade the most important packages at the expense of less important ones, if necessary. The /etc/apt/sources.list(5) file contains a list of locations from which to retrieve desired package files. See also apt_preferences(5) for a mechanism for overriding the general settings for individual packages.

Can I enter both apt-get update and apt-get upgrade command at once?

Yes, you can do that using the usual AND operator (&&). Here’s how it will look like:

sudo apt-get update && sudo apt-get upgrade

All apt-get Linux Commands

As I mentioned, apt-get commands are used to manage the packages on your Linux machine. So, there’s a lot more useful stuff that you can do with it. Let us take a look at all the possible commands using apt-get to manage the packages on your Linux distro.

Note: All these commands – except the ones for searching – requires the use of “sudo” as the prefix.

1. Installation Linux Commands

apt-get install 

You can install a package using this command. The exact syntax for it is:

sudo apt-get install <insert package name here>

For multiple package installations, you can just add the package names followed by a space, like:

sudo apt-get install <package name 1> <package name 2> ....

apt-get build-dep

If you need to install the build dependencies for a package, you can do that using:

sudo apt-get build-dep <insert package name here>

2. More Maintenance Linux Commands

apt-get check

It verifies the integrity of the dependencies. There’s no special syntax to use it:

sudo apt-get check

apt-get autoclean

It helps to clean up the .deb files of the packages that are no longers installed on your computer. You could utilize it to free up some space:

sudo apt-get autoclean

apt-get clean

This command deletes all the packages that reside in your package cache. So, in order to install it, you need to re-download them all.

sudo apt-get clean

3. Removal Commands

apt-get remove

If you do not want to delete the settings of a package, but want to uninstall it temporarily. You can do that using this command:

sudo apt-get remove <insert package name here>

apt-get purge

Want to remove the package completely? Including the configuration files? Here’s what to type in:

sudo apt-get purge <insert package name here>

apt-get autoremove

There are some packages installed by other packages to facililate the operation. So, if you aren’t using the primary package, you don’t need the additional packages that was associated with it. To remove such kind of packages, type:

sudo apt-get autoremove

4. Search Commands

As we mentioned earlier, you do not need root privileges while using these type of commands. So, let’s take a quick look at the command:

apt-cache

When you need to find a package – before installing it – then you can search for it using this command:

apt-cache search <insert search term here>

Here, it will initiate listing the packages whose name or description contains the search term – so you do not need to know the exact package name.

Now, when you know the package name, you can enter another command to know the details of it:

apt-cache show <package name>

Wrapping Up

Now that you know about all the necessary apt-get linux commands and the purpose of sudo apt-get update command, you should be easily able to manage the packages on your Linux machine.

If you have a different package management system, and you’re having a doubt on it – let us know in the comments below and we’ll help you with it.

Related Resources:

  1. 20 Wget Command Examples to Do Cool Things with Wget Commands in Linux
  2. Best Linux Task Manager to Kill Task on Linux
  3. Top 12 Best Linux Distros for Beginners
  4. How to Use Google Drive for Linux?

Meet Author

Ankush Das

Ankush Das a.k.a. CEO_&[email protected](.in), is a very energetic person who always puts up an evil smile to counter any obstacle in his way. This dude is highly unpredictable and in fact, you can’t know what’s coming from him… be it his articles, generating an aura, or his personality. Here, he mostly covers stuff on the most popular mobile operating system (Android).

0 comments… add one

Leave a Comment

Pin It on Pinterest

Share This