Apt-Get Update vs Apt-Get Upgrade – Linux Hint

The apt-get update and apt-get update are two of the most common Linux commands. You can’t escape them, so making peace by understanding their difference is your best solution. Also, whenever you need a clean installation of packages, you should use both commands. If you don’t understand what the two commands entail and what their differences are, stick around and learn.

Working with

APT on Linux

Packages are installed, updated, and removed using the APT package manager on Linux. Ubuntu and Debian are the common distributions where you come across the Advanced Package Tool (APT). apt-get update and apt-get upgrade are examples of commands that fall under APT.

You cannot use the apt if you use the other distributions such as CentOS. Instead, you can use package managers such as YUM.

Linux

Apt-Get Update

Any package installed on Linux has its package information stored on the system. As the new version is released, the Linux system maintains a tab of information that changes for each package. It accomplishes this by using the apt-get update or apt update command. When run, the apt-get update downloads the package information that is defined in the source file.

The package information is stored in /etc/apt/sources.list which contains the URLs that indicate where to get each package.

You can view the listed fonts using an editor of your choice or using other commands such as cat. The list of sources is different depending on your region.

Apt Get Update vs Apt Get Upgrade 1

Once the command is executed, the system knows which packages need to be updated based on the information retrieved. If all packages are up to date

, you can get the following: Apt Get Update vs Apt Get Upgrade 2

In some cases, you get the following output indicating that some packages need to be updated.

<img src="https://linuxhint.com/wp-content/uploads/2022/08/Apt-Get-Update-vs-Apt-Get-Upgrade-3.png" alt=

” />

Linux apt-get upgrade

When you run the apt-get update command and get that some packages need to be updated, that’s when you run the apt-get update. The apt or apt-get update update uses the information obtained to update all installed packages to the latest version. It only updates installed packages and not new ones.

For example, we can update the packages identified in the image above as shown below:

Apt Get Update vs Apt Get Upgrade 4

Now that we cover the apt-get update and upgrade commands, let’s understand their differences. Difference between

apt-get update and apt-get upgrade

The apt-get update is responsible for updating the package information using the URLs defined in the source list. Once the information is updated, the apt-get update takes over and updates all installed packages to the latest version. Any package without a recent version is ignored.

That’s the difference between the two commands. And in most cases, you may notice that they are used side by side. Always remember to update before upgrading. When you install a new package, upgrade the apt database, install the package, and then upgrade the system.

Also, running apt-update before installing a tool ensures that you get the latest version of the tool you want to install. If you want to update only one tool, say git, you only need to run the next two commands without the apt-get update.

Apt Get Update vs Apt Get Upgrade 5

Note that the

output indicates that git is already the latest version. This is because we first run the apt-get update command.

If you need to update and update all packages, you can combine the two commands and run one command.

Apt Get Update vs Apt Get Upgrade 6

You may notice that the system updates the package information first and proceeds to update the packages if something needs an update. In the above output, all packages are up to date.

Conclusion

You might easily get confused about why you need to run the apt-get update and apt-get upgrade commands on your system, especially if you are a beginner. We have covered each command separately and discussed their differences. With that, you can now conveniently use your system’s apt-get update and apt-get upgrade commands.

Contact US