Keeping your operating system up to date is the single most important step you can take to maintain the security and stability of your computer. While Ubuntu Linux offers a graphical “Software Updater” application that makes this process user-friendly, many users prefer or require the command line. Using the terminal is significantly faster, provides detailed feedback on exactly what is being installed, and is absolutely essential if you are managing an Ubuntu server without a graphical interface.
In this guide, we will walk through the standard process for keeping your Ubuntu system perfectly updated using the Advanced Package Tool (APT).
The Two-Step Update Process
Updating an Ubuntu system via the terminal is a two-part process. First, you must tell the system to check for available updates. Second, you must tell the system to actually download and install those updates.
Step 1: Refresh the Package List (apt update)
Your Ubuntu system keeps a local database of all available software and their current versions. Before you install anything, you need to synchronize this local database with the remote Ubuntu servers so your computer knows what new versions exist.
Open your terminal (Ctrl + Alt + T) and run the following command:
sudo apt update
Because installing software requires administrative privileges, you must use sudo. The terminal will prompt you to enter your user password. (Note: As you type your password, no characters or asterisks will appear on the screen. This is normal security behavior in Linux. Just type it and press Enter).
The system will connect to the Ubuntu repositories. Once finished, it will output a message telling you how many packages can be upgraded.
Step 2: Install the Upgrades (apt upgrade)
Now that your system knows which updates are available, you need to apply them. Run the following command:
sudo apt upgrade
The terminal will display a list of all the software packages that are about to be upgraded, along with the total download size. It will pause and ask for your confirmation: Do you want to continue? [Y/n].
Press Y and hit Enter. The system will now download and install all the latest security patches, bug fixes, and software updates.
Combining the Commands for Speed
If you update your system frequently and want to save time, you can chain these two commands together into a single line. Furthermore, you can pass the -y flag to automatically answer “Yes” to the confirmation prompt.
sudo apt update && sudo apt upgrade -y
The && operator tells Linux to run the second command only if the first command completes successfully. This single line is all you need to type to fully update your system in one go.
Housekeeping: Removing Unnecessary Packages
Over time, as software is updated, old dependencies (libraries and background packages that were required by older versions of software) are left behind on your hard drive. These orphans take up valuable disk space.
To safely remove packages that were installed automatically but are no longer needed by any program, run:
sudo apt autoremove
It is a good habit to run this command once a month after performing a standard system upgrade.
Conclusion
Updating Ubuntu via the command line is quick, reliable, and provides maximum transparency. By regularly running apt update and apt upgrade, you ensure your Linux environment remains secure against vulnerabilities and performs at its best.