Updating an operating system is a critical task that ensures the system’s security, stability, and performance. In Ubuntu, updating the system involves running several commands in the terminal. In this technical post, we will explain the process of updating an Ubuntu Server installation and how to fix the issue of pending package upgrades.
The first command that needs to be executed is
sudo apt update. This command updates the list of available packages from the Ubuntu repositories. The
-y option instructs the system to answer “yes” to prompts, ensuring the process runs uninterrupted.
The second command is
sudo apt upgrade. This command upgrades all installed packages to their latest versions. Again, the
-y option is used to answer “yes” to any prompts.
The third command,
sudo apt autoremove, removes any unnecessary dependencies that are no longer required by the system.
After executing these three commands, the system displayed a warning message that says that five packages can be upgraded. To see the list of upgradable packages, we needed to execute the command
apt list --upgradable. This command lists all the upgradable packages along with their versions.
The following command we executed was sudo apt-get dist-upgrade. This command upgrades the system to the latest distribution release, including kernel upgrades. However, the command failed to upgrade the pending packages in this case.
To fix the issue, we executed the command
sudo apt-get install --only-upgrade $PACKAGE for each pending package. This command upgrades the specified package to its latest version. The
$PACKAGE variable should be replaced with the package name that needs to be upgraded.
In summary, updating an Ubuntu Server installation involves running the
sudo apt update,
sudo apt upgrade, and
sudo apt autoremove commands in the terminal. If there are any pending package upgrades, we can use the
apt list --upgradable command to see the list of upgradable packages. If the
sudo apt-get dist-upgrade command fails to upgrade the pending packages, we can use the
sudo apt-get install --only-upgrade $PACKAGE command to upgrade each package individually.