How to Upgrade Ubuntu Packages VIA Command Line

Keeping packages up-to-date is an important part of maintaining a secure Linux system and ensuring you have the latest package features available.

 

In this tutorial, we will learn how to update packages on your Ubuntu system.

 

Updating Ubuntu Repository List

To update your Ubuntu package manager with the latest list of repository updates run the following command:

 

sudo apt update
243 package can be upgraded run 'apt list --upgradable' to see them.

 

Review What Packages can be Upgraded

If you would like to see what packages can be upgraded use this command:

 

apt list --upgradable

 

If there are a lot of them you can narrow down the list by typing the first few letters of the package at the end of the command followed by * (RegEx all)

 

apt list --upgradable python*

 

Upgrade a Single Package Only

To upgrade a single package on your Ubuntu system run:

 

sudo apt-get install --only-upgrade package-name

 

Replace package-name with the name of the package you would like to upgrade.

 

Upgrade All Packages

To upgrade all packages to the latest available version use the following command:

 

Caution – if you have custom modules enabled in PHP, or other similar software situations updating all your packages may disable them. Be aware of this before doing a full upgrade and observe any confirmation dialogues Ubuntu gives you carefully.

 

sudo apt upgrade
Need to get 258 MB of archives.
After this operation, 203 MB of additional disk space will be used.
Do you want to continue? [Y/n]

 

Press Y then ENTER to confirm any confirmation dialogues, or N then ENTER to bail out of the operation and make no further changes.

 

To handle changing dependencies and remove obsolete packages run dist-upgrade like this:

 

sudo apt dist-upgrade

 

Add Security Updates Only

Upgrade all your packages at once may cause things to break so you may not want to take the risk. However, if you just want to get Linux security updates you can run:

 

sudo apt install unattended-upgrades
ubuntu