4th gen AMD EPYC coming soon Pre-order now

What does sudo apt update do? [A Complete Overview]

December 29th, 2023
What does sudo apt update do? [A Complete Overview]

As you become familiar with your Debian-based system, you will inevitably encounter features you don't understand. One such feature may be the sudo apt update command, a basic Linux/Debian system administration command. This guide will explain what sudo apt update does, what it is, and why updating software is important.

What is sudo apt update?

The sudo apt update command is a Linux/Debian system administration command that updates the list of available packages and their versions stored in the system's package index.

Here’s a breakdown of the sudo apt update command structure and basic usage:

  • sudo: Sudo is a shortened form of the phrase "super user do", which means it refers to seeking and being granted privileges to execute administrative/ root user commands;
  • apt: The word "apt" refers to software package management for Debian-based systems and stands for "advanced package tool". Apt allows you to manage packages on a Debian-based Linux distribution (often called distro, this is the operating system) — the likes of Debian, Ubuntu, Linux Mint, Kali Linux, or Raspberry Pi OS.
  • update: This refers to the command’s action and what the command will do: order and obtain a refreshed list of available packages from the distro’s repositories (repos), but without upgrading (installing) updated packages.

sudo apt update vs. sudo apt-get update

sudo apt update vs. sudo apt-get update are effectively the same command. Apt is the new package management tool replacing apt-get in newer Debian/Ubuntu versions. However, apt-get is still fully supported, and they both synchronize the package index file for the local system. To summarize, sudo apt update vs. sudo apt-get update performs the same task.

What does sudo apt update do?

sudo apt update connects to the configured package repositories and retrieves the latest package lists. When users type the sudo apt command into their distro system, they order the system to give them a list of the latest software packages available to install.

A user can then command the system to install (or ‘upgrade’) any or all the available packages using the sudo apt upgrade command. Sudo apt update ensures your system has the latest information on available packages and their versions before installing or upgrading packages.

For example, when installing Docker on Ubuntu, sudo apt update is necessary because without it, apt would not be aware of the latest available package versions, which could result in installing older versions. Skipping this step could lead to packages failing to install or version conflicts. Hence, to ensure a clean and problem-free Docker setup, it is a short but essential step before the installation.

Why run sudo apt update?

Let’s focus on why run sudo apt update and what the sudo apt update command leads to.

Refresh repositories

If you use a Linux system, it's not only important to install updates but also to routinely check if new updates are available. Why? Well, it comes down to Linux's reliance on repositories.

Distros depend on their repos as shared libraries of code, which means the repos are in heavy, constant use. Linux distros don't prompt users as soon as package updates are available. The onus is on users themselves to remember to check.

Therefore, it is doubly important when considering different Linux distros use different schedules for updates. This means that rolling-release distros like Arch tend to release packages swiftly after their release by upstream developers. Ubuntu, Linux Mint, or other distros may not do the same thing.

So, running the sudo apt update command ensures you refresh your repo lists and immediately discover available software updates.

Update package information and verify available updates

The sudo apt update command will update package information so you can verify available updates. How do you do this? To enter any commands, you'll need to open the terminal window.

Note: It's important to note that a terminal goes by a different name on different distros. For instance, the default terminal in Ubuntu and Linux Mint is 'Gnome Terminal.' Yet, their application menus may refer to it as 'Terminal.'

Once you've opened a terminal window, type in 'sudo apt update' (or 'sudo apt-get update'), then your admin password, and press Enter. Should any package updates be available, a terminal read-out will appear, much like the one above.

After updating the package information, you should check exactly what updates can be upgraded. If upgradeable packages are available, you will be prompted to use the command' apt list --upgradable' (see the bottom line in the above image). Running this command will produce a list of upgradable packages.

sudo apt update example sudo apt update example. Source: embeddedinventor.com

sudo apt update vs. sudo apt upgrade

Let's understand the distinction between the sudo apt update vs. sudo apt upgrade command. Typing in the sudo apt update command won't install package updates to the distro but brings up a list of the latest package updates available in the repo. Then, the sudo apt upgrade command downloads new available packages to a user's distro.

However, just as an IT engineer should take great care in executing a business's data migration from legacy systems, a Debian user is encouraged to take a fair degree of care when running the upgrade command.

All Debian-based terminals will allow you to review your chosen upgrades before confirming them and completing the downloads. How? Before completing the upgrade, enter your password, type 'y' to confirm, and press Enter. It's a reassuring safety feature built into the command structure to ensure users install the upgrades they want from the available depo list.

sudo apt update not working—handling errors and troubleshooting

Unfortunately, running the sudo apt update command can sometimes result in error message issues. While such 'errors' aren't as significant a headache for Linux users as, say, an email SPF validation error may be for a marketing department, they can still be a hassle.

Here are some of the common errors:

Error: When running the sudo apt update command in Ubuntu, you may encounter a 'held package' message in the terminal, which indicates a new package exists but isn't available to upgrade.

Solution: This issue, however, can be swiftly resolved by running another command: sudo apt clean, sudo apt autoclean, or sudo apt autoremove.

Error: Additionally, after typing the sudo apt command, a user may encounter the following message:

“Some packages could not be installed. This may mean that you have requested an impossible situation or if you are using the unstable distribution that some required packages have not yet been created or been moved out of Incoming.”

Solution: You can solve this error by running the command sudo apt full-upgrade (instead of the sudo apt upgrade). Why? Because it should free up space by removing already installed packages while upgrading new ones.

However, it can be a risky move. Unfortunately, the full-upgrade command could try to uninstall important packages, resulting in an unusable distro. Not a scenario anyone would want—having to rely on backup storage to retrieve important files, data, and more.

So, the best idea here may be to pause and wait a few days for the available upgradable packages to change. Hopefully, this ‘error’ message won’t reappear because there should now be better updating options.

Error: Lastly, users of kali-dev or kali-experimental (developmental versions of Kali Linux) can sometimes receive messages claiming specific packages aren’t yet available.

Solution: This may be because the package will be available soon but is still being tested. In this case, the package should become available within a couple of weeks.

person using a laptop Source: Free-to-use image sourced from Unsplash.

How often should you use sudo apt-get update?

There's no fixed schedule for how often you should run sudo apt update. However, doing it at least once a week at minimum is good practice. Consider running it after significant package changes, before upgrades, or anytime install/upgrade errors occur related to missing packages. Daily is also safe if you update packages frequently to take advantage of all possible software packages.

Why are software updates important?

Most users appreciate that running software updates on a PC, smartphone, or PaaS software helps it run better and faster because the new update may replace an outdated feature. Yet, updates also tend to deliver other equally important benefits.

For example, updates boost protection from cyber threats by fixing the security issues of older features by plugging the gaps and providing improved security elements. Should such gaps not be filled, they can be exploited and compromised by malware attacks, leading to stolen data.

Software updates also improve device performance by fixing bug issues. Many devices run slower as they age because they haven’t been exposed to the software updates they should have. While many devices lose performance over time, updates can slow this process. As a result, systems prompt users to install updates, thereby resolving issues and improving performance.

It’s, therefore, in the best interest of a device user to install software updates as and when they become available.

coding image Source: Free-to-use image sourced from Unsplash.

Final thoughts

When run together, the sudo apt update and sudo apt upgrade commands ensure installing software updates is relatively straightforward and hassle-free on Debian-based distros, playing a crucial role in keeping them healthy, functional, and performing as they should.

Debian-based Linux users—just like the users of any other systems—must stay on top of the latest program and application updates. They enable systems to run smoother and faster by exposing them to the latest advances, fixing bugs, and plugging security gaps.

I'm a keen technology enthusiast with strong interest in GPU computing and DevOps culture. I believe Agile development helps companies reach utmost customer satisfaction and makes their services stand out in the market.

Cloud VPS - Cheaper Each Month

Start with $9.99 and pay $0.5 less until your price reaches $6 / month.

We use cookies to ensure seamless user experience for our website. Required cookies - technical, functional and analytical - are set automatically. Please accept the use of targeted cookies to ensure the best marketing experience for your user journey. You may revoke your consent at any time through our Cookie Policy.
build: e4941077.621