Keeping Your Linux System Up-to-date With APT

Check out our beginner friendly guide where we will discuss how to keep your Ubuntu, Debian, and derivatives up to date with the apt command.

On this page
  1. Updating And Upgrading
  2. Conclusion
  3. Additional Links

Debian-based Linux distributions use .deb files for installing packages. These deb files are then stored in a central repository to make retreating these files easy. This is where a package manager like apt comes into play as it allows you to search and install packages from those remote package repositories. In this post, we will discuss how to keep your Ubuntu, Debian, and derivatives up to date with the apt command.

What Is Apt?

The apt package manager allows you to install, upgrade, configure, and remove software packages. Packages being installed are retrieved from remote repositories specified in /etc/apt/sources.list and /etc/apt/sources.list.d/.

What Are The Differences Between Apt And Apt-get?

You may have seen references to apt-get update and upgrade. Apt was introduced after apt-get to solve usability concerns building on what was learned with apt-get. You would be surprised to know that apt-get is part of apt nowadays.

What Does Sudo Apt Update Do?

The update flag of the apt command tells the system to retrieve updated information about the available packages available in the configured remote repositories.

What Does Sudo Apt Upgrade Do?

The upgrade flag downloads and installs the available software updates from the configured remote repositories. It should be noted that this will only install updates for your current Operating System version. There are different commands used when upgrading from one OS version to another.

What Is The Connection Between Apt Update And Apt Upgrade?

Both these commands are mutually important to install updates on your Debian-based system. This is because without accurate information about what software packages and versions are available apt cannot retrieve and install software updates.

To simplify if you run an apt upgrade without accurate package information from the apt update there is a good chance the upgrade will error out.

How Often Should Update?

Personally with standard updates (non-security related) installing them once a week is just fine. The one exception is security updates these I would recommend installing as soon as possible. Ideally, I would recommend installing them automatically once a day. Check out the package unattended-upgrades for automated installation of security updates.

#Updating And Upgrading

  1. To upgrade and update your system first start off by running the update command as shown below:sudo apt updateAssuming everything works without a hitch you will see “All packages are up to date”Results of sudo apt update
  2. Next is to run the upgrade command as shown below:sudo apt upgradeIt will provide you with a list of changes it wants to perform, and it will ask for confirmation by entering the letter y and enter.First section of sudo apt upgrade results up till "do you want to continue".After confirming the upgrade it will fetch, unpack, and setup the updated software packages.Once complete you will be returned to the command line.
  3. Optional: Although it is not a requirement some updates require a restart to take full effect for example kernel updates. To check to see if the file /var/run/reboot-required exists, if it does a reboot is required to finish the updates.

#Conclusion

The Apt package manager is used as the system’s primary package manager on systems like Ubuntu, Debian, and other derivatives. In this post, we have discussed background like what apt is, what the update and upgrade subcommands do, how they work together, and more. Ending with how to use both commands to update software packages and that in some cases a reboot may even be required.

Done with this post and looking for more, why not check these links out?

Illustrated avatar of CJ Saathoff
Written by

CJ Saathoff

CJ Saathoff writes for the NameHero blog.

More from CJ →