Skip to main content

How to Update Ubuntu

Summary

Step-by-step process to update Ubuntu, including updating package lists, upgrading packages, performing a full upgrade if needed, and cleaning up unused files. It also offers troubleshooting tips for resolving issues like held packages or broken dependencies.

Introduction #

Keeping an Ubuntu system updated is important for maintaining security, stability, and access to the latest features. This guide explains the steps and commands necessary to update an Ubuntu system via terminal/command line, as well as troubleshooting tips if packages do not upgrade as expected.

Updating and Upgrading #

Step 1: Update the Package Lists #

The first step is to ensure that Ubuntu has the latest information about available updates. This is done using the sudo apt update command.

sudo apt update

Running this command fetches the latest package information from the repositories specified in /etc/apt/sources.list.

Step 2: Upgrade Packages #

After updating the package lists, you can upgrade installed packages to their latest versions. This is done using the sudo apt upgrade command.

sudo apt upgrade

You will be prompted to confirm the upgrade. The prompt typically appears as Y/n or y/N.

Type the appropriate choice and press Enter to continue.

Step 3: Perform a Full Upgrade (Optional) #

In some cases, a simple sudo apt upgrade might not be sufficient. If there are updates requiring the installation of new packages or the removal of outdated ones, use the sudo apt full-upgrade command.

sudo apt full-upgrade

Use the full-upgrade command with caution and review the changes carefully.

Step 4: Verify the Updates #

To ensure the updates were applied successfully, you can check the status of your system using the following command:

sudo apt list --upgradable

If no packages are listed, your system is fully updated.

Clean Up Unused Packages #

To free up disk space and remove unused packages, use the autoremove command.

sudo apt autoremove

You can also clean up cached package files to reclaim space:

sudo apt autoclean

Troubleshooting: What to Do if Packages Are Not Upgraded #

If sudo apt upgrade does not update some packages, try the following steps:

  1. Run a full upgrade:
    sudo apt full-upgrade
    

    This command resolves dependencies and applies all updates.

  2. Check for held packages:
    Held packages may prevent upgrades. Check for them with:
    sudo apt-mark showhold
    

    If there are held packages, unhold them with:

    sudo apt-mark unhold <package_name>
    
  3. Manually upgrade packages:
    If a specific package is not upgrading, manually update it:
    sudo apt install --only-upgrade <package_name>
    
  4. Fix broken dependencies:
    If there are issues with dependencies, run:
    sudo apt --fix-broken install
    
  5. Refresh keys and repositories:
    If there are errors fetching updates, refresh the GPG keys or repositories:
    sudo apt-key adv --refresh-keys
    sudo apt update
    

If issues arise, check for held packages, manually upgrade, or fix broken dependencies.


Further readings #

Sources and recommended, further resources on the topic:

Author

Jonas Jared Jacek • J15k

Jonas Jared Jacek (J15k)

Jonas works as project manager, web designer, and web developer since 2001. On top of that, he is a Linux system administrator with a broad interest in things related to programming, architecture, and design. See: https://www.j15k.com/

License

License: How to Update Ubuntu by Jonas Jared Jacek is licensed under CC BY-SA 4.0.

This license requires that reusers give credit to the creator. It allows reusers to distribute, remix, adapt, and build upon the material in any medium or format, for noncommercial purposes only. To give credit, provide a link back to the original source, the author, and the license e.g. like this:

<p xmlns:cc="http://creativecommons.org/ns#" xmlns:dct="http://purl.org/dc/terms/"><a property="dct:title" rel="cc:attributionURL" href="https://www.ditig.com/instructions/how-to-update-ubuntu">How to Update Ubuntu</a> by <a rel="cc:attributionURL dct:creator" property="cc:attributionName" href="https://www.j15k.com/">Jonas Jared Jacek</a> is licensed under <a href="https://creativecommons.org/licenses/by-sa/4.0/" target="_blank" rel="license noopener noreferrer">CC BY-SA 4.0</a>.</p>

For more information see the DITig legal page.


“Less is more.”

Ludwig Mies van der Rohe, German architect and designerWord of mouth, - IT quotes