How to Update Ubuntu Using the Command Line?

Ubuntu is known for its ease of use and stability which is a widely used Linux distribution. Keeping the Ubuntu system up-to-date is important for performance, getting the latest features, and security. In addition,  it can prevent potential vulnerabilities and improve your overall experience with Ubuntu. 

While Ubuntu offers graphical tools for updates, using the command line can be faster, more efficient, and gives you greater control. It is useful for managing remote servers or when working without a graphical interface.

This article will explain to you how to update your Ubuntu system using the command line, which is an essential skill for any Ubuntu user.

  1. How to Update Ubuntu Using the Command Line?
  2. How to Update the Ubuntu Kernel Using the Command Line
  3. How to Update Ubuntu Remotely Using the Command Line
  4. Bonus Tip: How to Update Ubuntu Using GUI
  5. Conclusion

How to Update Ubuntu Using the Command Line?

Updating Ubuntu using the command line is a simple task that ensures the system is up-to-date and secure. Let’s update Ubuntu through the CLI:

Step 1: Update Package List

The first step in updating the system is to refresh the list of given packages. It synchronizes sources with the package index files:

sudo apt update
Update Ubuntu Using the Command Line

It’s a safe operation that won’t change your system but allows you to see the latest available updates.

Step 2: Upgrade Packages

After updating the package list, users need to upgrade all the installed packages in the Ubuntu system to their most recent versions. It downloads and applies updates for all packages that have the latest versions available. It does not remove any packages unless necessary to resolve a package conflict:

sudo apt upgrade
Update Ubuntu Using the Command Line 1

Step 3: Full Upgrade (Optional)

For a more thorough update, users can use the “full-upgrade” utility with the apt command. This command performs the same function as “apt upgrade” but will also remove installed packages if they prevent the upgrade of another package or are no longer needed:

sudo apt full-upgrade
Update Ubuntu Using the Command Line 2

Step 4: Install Specific Package Updates (Optional)

For updating the specific package, users can execute the <sudo apt install package-name> command. For instance, install the gnome-shell package:

sudo apt install gnome-shell
Update Ubuntu Using the Command Line 3

Note: Users can replace “gnome-shell” with the actual name of the package they wish to update.

Step 5: Clean Up

After upgrading, remove packages that are no longer required:

sudo apt autoremove
Update Ubuntu Using the Command Line 4

Step 6: Reboot (If Necessary)

For kernel updates, users may need a reboot to save changes. If prompted, then reboot the system with the below command:

sudo reboot

Remember, it’s always recommended to back up your data before performing system updates, especially when upgrading to a new release.

How to Update the Ubuntu Kernel Using the Command Line

One of the critical components that often needs updating is the Linux kernel. For updating the Ubuntu kernel using the command line, follow the below steps:

Step 1: Checking Your Current Kernel Version

Before updating the kernel, it’s essential to check the version you’re currently running. It displays the current kernel version which is “6.8.0-31-generic”:

uname -r
Update Ubuntu Using the Command Line 5

 Step 2: Updating Package Database

After that, update the package list. It ensures that you have the latest package lists before proceeding with the kernel upgrade:

sudo apt update
Update Ubuntu Using the Command Line 6

Step 3: Searching for Available Kernel Versions

To find out the available kernel versions, use the below command. It lists all the available kernel images that you can install:

apt-cache search linux-image
Update Ubuntu Using the Command Line 7

Step 4: Installing the Kernel

Once you’ve identified the kernel version you wish to install, users can proceed with the installation using the below command:

sudo apt install linux-image-<version>
Update Ubuntu Using the Command Line 8

Replace “version” with the kernel version number you’ve chosen. 

Note: Ubuntu 24.04 has pre-installed the latest kernel version named “linux-image-6.8.0-31-generic”. 

Step 5: Rebooting Your System

After the installation is complete, users are required to reboot the system:

sudo reboot

Important Note: Remember that installing a new kernel doesn’t remove the old one. 

Finally, you have successfully updated your Ubuntu kernel using the command line.

How to Update Ubuntu Remotely Using the Command Line?

Here’s a step-by-step guide on how to update Ubuntu remotely using the command line:

Prerequisite: Install SSH on Ubuntu 24.04

Before updating Ubuntu remotely, users need to execute the below commands for installing SSH on the Ubuntu system:

sudo apt install ssh    # Install SSH
sudo ufw enable         # Enable Firewall
sudo ufw allow ssh      # Allow SSH Connections
sudo ufw reload         # Reload Firewall Rules

Step 1: Securely Connect to Your Server


The first step is to make a connection (securely) to the server using SSH. For this, open a terminal on the local machine and use the ssh command with “username” and “server-address”:

ssh username@server-address
Update Ubuntu Using the Command Line 9

Note: Replace “username” with your actual username and “server-address” with the IP address or domain of your Ubuntu server.

Step 2: Update Package List

Once connected, update the list of available packages to make sure that users are acquiring the latest versions:

sudo apt update
Update Ubuntu Using the Command Line 10

Step 3: Upgrade Packages

Now, install available updates for all packages currently installed on the systems:

sudo apt upgrade
Update Ubuntu Using the Command Line 11

Step 4: Handle Distributions Upgrades (Optional)

Sometimes, a standard upgrade isn’t enough, especially if there are kernel updates or other critical system components. In such cases, use the following command:

sudo apt dist-upgrade

This command will handle changes with new dependencies and smart conflict resolution.

Bonus Tip: How to Update Ubuntu Using GUI

The Software Updater will check for available updates for your system. This includes updates for the core operating system, installed applications, and various system components.

To update Ubuntu via the GUI, open the Software Updater, check for updates, and review the updates. Finally, install the updates by clicking on the “Install Now” button.

Update Ubuntu 24.04 b

Some updates may need the operating system restart to accomplish the installation process. 

Update Ubuntu 24.04 a

By following these steps, users can easily keep their Ubuntu system up-to-date using the GUI, ensuring a secure and efficient computing experience.

Conclusion

To update Ubuntu using the command line, Open the terminal application and execute the command “sudo apt update” to refresh your package list. Then, use the “sudo apt upgrade” to install available updates. If a new kernel version is available, it may need a rebooting system to complete the update process. Always ensure that you have a backup of your system before performing updates, especially when upgrading to a new release version.