How to Update Packages on Ubuntu Command Line


Ubuntu, like other operating systems, provides frequent updates which aim to fix bugs and make any minor fixes or changes. Updates can be acquired from the terminal where printing the upgradeable packages list is possible. This list includes all newer packages available, allowing you to upgrade one at a time or multiple packages at once. Updating packages and operating systems is critical to bringing users new functionalities and better performance. Keeping your software up-to-date is essential for security reasons and gives access to the latest features available on the platform. The following guide will cover updating packages on the Ubuntu command line.

Check for updates command Ubuntu

Running the update command on Ubuntu Linux is easy and provides users access to new versions of packages installed on their system. By using the “apt-get update” command in the terminal, users can quickly query repositories for available updates. This helps to ensure that they can benefit from any bug fixes, security patches, and other enhancements as soon as they are released, keeping their system secure and up to date.

Here’s the syntax of the command.

sudo apt-get update

It’s important to run this command with “sudo” as it requires administrative privileges.

You can also use the following newer version of the APT command to update the package list on Ubuntu Linux.

sudo apt update

Example output:

Upgrade packages command Ubuntu

Following running an update on your Ubuntu terminal, you now need to proceed with the upgrade. You can run the standard upgrade commands with apt or apt-get or upgrade packages individually. Sometimes you may want to review the list of upgrades, and this can be found further on.

It’s a good practice to run this command before you run the upgrade command, which upgrades the packages on your system.

sudo apt-get upgrade

Or using the new method.

sudo apt upgrade

Example output:

This command upgrades all the packages that have updates available.

Note: It’s a good practice to run these commands regularly to ensure that your system runs the latest and most stable software versions.

Lastly, if you need time to review some upgrades on certain packages but immediately require an upgrade on a specific package, you can run the following example.

sudo apt-get upgrade <package name>

Or previously stated, with the new method.

sudo apt upgrade <package name>

List upgradeable packages Ubuntu

To list upgradeable packages in Ubuntu, you can use the apt command with the list –upgradable option.

You can use the following command in the terminal.

sudo apt update
sudo apt list --upgradable

This command first updates the package list from the repositories and then lists all the packages that have updates available.

Alternatively, you can use the following command to list all upgradable packages.

apt list --upgradable

Example output:

You can also use the package manager GUI, like Ubuntu Software, to check for updates and upgrade packages.

Note: Upgradable packages have a new version available in the repositories.

Another way to list upgradeable packages is by using the apt-show-versions command.

apt-show-versions -u

This will show all upgradeable packages.

Example output:

If the above command does not work, you must install the apt-show-versions package with the following terminal command.

sudo apt install apt-show-versions -y

Then re-run the “apt-show-versions -u” command.

Full upgrade or dist-upgrade command Ubuntu

The apt-get dist-upgrade and apt full-upgrade commands are used to upgrade all packages on Ubuntu. They upgrade the packages to their latest version available in the repositories, including upgrading packages with new dependencies or packages that may be removed.

See also
How to Install Neofetch on Rocky Linux EL9 or EL8

For users new to Linux and Ubuntu-based distributions, the apt-get dist-upgrade command is the older command version. It is used to upgrade packages and automatically handle any new dependencies the upgrades may introduce. This may include installing or removing new packages that are no longer required. The apt full-upgrade is the new version of the command. It is the equivalent of the apt-get dist-upgrade command, has the same functionality, and is more user-friendly.

For most users, these commands should only be used when upgrading between Ubuntu operating system versions, for example, 20.04 LTS to 22.04 LTS, or you require a significant system upgrade. Now for some example commands below, always run the update command before any upgrade command.

sudo apt-get update
sudo apt-get dist-upgrade

Or using the newer method with full-upgrade command.

sudo apt update
sudo apt full-upgrade

It’s important to note that running the upgrade command may require a system reboot, significantly if the kernel is upgraded. It’s also a good practice to run these commands regularly to ensure that your system runs the latest and most stable software versions.

You can also use the package manager GUI, like Ubuntu Software, to check for updates and upgrade packages.

Conclusion

In conclusion, upgrading packages on Ubuntu is essential to ensure your system’s security, stability, and performance. Regularly upgrading packages to their latest version helps to protect your system from known security threats by applying security fixes. It also ensures that your system runs the most stable and reliable software versions with bug fixes, new features, and improvements. Additionally, upgrading packages provide that all the software on your system is compatible, which is essential for software that depends on other software for its functionality. Furthermore, upgrading packages can improve performance as newer software versions are often optimized to use system resources more efficiently. Therefore, it is a good practice to keep your Ubuntu system up-to-date by regularly checking for and installing available package updates.

Leave a Comment

Share to...