What does sudo apt-get update command do on Ubuntu/Debian?

September 8, 2019

Rate this post

I am a new Ubuntu / Debian Linux user. I wanted to know what does sudo apt-get update command does? What does it update and how do I tell apt-get to update? What does “sudo apt-get update” do on my Debian Linux server? What is the difference between “sudo apt-get update” and “sudo apt-get upgrade”?

Introduction: Debian and Ubuntu Linux are both free and open source operating system. Both systems use the Linux kernel and GNU commands. One can use apt command or apt-get command to manage software operations such as adding, removing, deleting, updating and so on. However new users often get confused with “sudo apt-get update” and “sudo apt-get upgrade” commands on a Debian or Ubuntu Linux system. After all, what does “sudo apt-get update” command do? This page explains the fundamental differences between the two commands.

What does sudo apt-get update command do?

  1. The sudo apt-get update command is used to download package information from all configured sources.
  2. The sources often defined in /etc/apt/sources.list file and other files located in /etc/apt/sources.list.d/ directory.
  3. So when you run update command, it downloads the package information from the Internet. It is useful to get info on an updated version of packages or their dependencies.

How to see /etc/apt/sources.list file

Type the cat command:
$ cat /etc/apt/sources.list

Run sudo apt-get update command to update package index

Simply type apt-get command or apt command:
$ sudo apt update
$ sudo apt-get update

What does sudo apt-get upgrade command do?

  1. Now you know sudo apt-get update command gets you an updated list of packages from the Internet.
  2. But, how do you install outdated packages? How do you apply security patches for packages and keep your system secure? How do you find new packages to install?
  3. You run sudo apt-get upgrade to install available upgrades of all packages currently installed on the system from the sources configured via sources.list file.
  4. New packages will be installed if required to satisfy dependencies, but existing packages will never be removed.

The differences between update and upgrade command

From the apt-get update man page:

update is used to resynchronize the package index files from their sources. The indexes of available packages are fetched from the location(s) specified in /etc/apt/sources.list. For example, when using a Debian archive, this command retrieves and scans the Packages.gz files, so that information about new and updated packages is available. An update should always be performed before an upgrade or dist-upgrade. Please be aware that the overall progress meter will be incorrect as the size of the package files cannot be known in advance.

From the apt-get upgrade man page:

upgrade is used to install the newest versions of all packages currently installed on the system from the sources enumerated in /etc/apt/sources.list. Packages currently installed with new versions available are retrieved and upgraded; under no circumstances are currently installed packages removed, or packages not already installed retrieved and installed. New versions of currently installed packages that cannot be upgraded without changing the install status of another package will be left at their current version. An update must be performed first so that apt-get knows that new versions of packages are available.


In short executing “sudo apt-get update” fetches you a list of packages for all of your repositories and PPA’s and make sure it is up to date. While “sudo apt-get upgrade” does an actual software upgrade. Hence, it recommended option is always to run update command before upgrade command to update installed packages for an Ubuntu or Debian system:
$ sudo apt-get update && sudo apt-get upgrade
One can run multiple commands in sudo as follows:
$ sudo sh -c 'apt update && apt upgrade'

Posted by: SXI ADMIN

The author is the creator of SXI LLC and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.