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
sudo
: Runs the command with administrative privileges.apt
: The Advanced Package Tool (APT), used for managing software on Debian-based systems.update
: Updates the local database of available packages.
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
sudo
: Runs the command with administrative privileges.apt
: The Advanced Package Tool (APT), used for managing software on Debian-based systems.upgrade
: Installs newer versions of the packages currently installed on your system, but it will not remove any packages or install new dependencies.
You will be prompted to confirm the upgrade. The prompt typically appears as Y/n
or y/N
.
Y/n
: The default choice is “Yes” (Y). Press Enter to accept the default and proceed with the upgrade. You can type “n” to decline.y/N
: The default choice is “No” (N). Press Enter to accept the default and cancel the upgrade. You can type “y” to proceed.
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
sudo
: Runs the command with administrative privileges.apt
: The Advanced Package Tool (APT), used for managing software on Debian-based systems.full-upgrade
: Installs updates even if they require adding or removing packages. This ensures your system is fully updated.
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
sudo
: Runs the command with administrative privileges.apt
: The Advanced Package Tool (APT), used for managing software on Debian-based systems.list --upgradable
: Lists all packages that still have available updates.
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
sudo
: Runs the command with administrative privileges.apt
: The Advanced Package Tool (APT), used for managing software on Debian-based systems.autoremove
: Removes packages that were installed as dependencies but are no longer needed.
You can also clean up cached package files to reclaim space:
sudo apt autoclean
sudo
: Runs the command with administrative privileges.apt
: The Advanced Package Tool (APT), used for managing software on Debian-based systems.autoclean
: Clears outdated package files from the cache.
Troubleshooting: What to Do if Packages Are Not Upgraded #
If sudo apt upgrade
does not update some packages, try the following steps:
- Run a full upgrade:
sudo apt full-upgrade
This command resolves dependencies and applies all updates.
- 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>
- Manually upgrade packages:
If a specific package is not upgrading, manually update it:sudo apt install --only-upgrade <package_name>
- Fix broken dependencies:
If there are issues with dependencies, run:sudo apt --fix-broken install
- 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:
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.”