How to make updating Ubuntu simpler
Ubuntu can be updated from the command line, and from the GUI. If you decide to update Ubuntu via the command line, you’ll find there are quite a few steps to the process. To make things simple, you can create a script that will handle the entire update process. Creating the script will take a little time but once you have it set up, you will be able to use it to update Ubuntu whenever a new update is available. Here’s what you need to do.
Easy update script
Making Ubuntu much easier to update starts with creating an “easy update script.” This script will take care of everything from updating package sources, installing Ubuntu upgrades, cleaning packages that need to be removed, and even refreshing things like Snaps and Flatpaks!
To start the process of creating the easy update script, open up a terminal window on your computer. A terminal window can be opened by pressing Ctrl + Alt + T or Ctrl + Shift + T. Once the terminal is open, follow the step-by-step instructions below to create the script.
Step 1: Using the touch command, create a new blank file called “update.” The “update” file will hold all of the upgrade operations on your Ubuntu PC.
touch update
Step 2: After creating the new update file with the touch command, it is time to access it for editing purposes. Open up the “update” file in the Nano text editor.
nano -w update
Step 3: Inside of the Nano text editor, write the code below. Be sure that this code is on the very first line, or it will not work correctly!
#!/bin/bash
The code above you’ve just added to the “update” file is called a shebang. It tells the interpreter what to do with your script.
Step 4: Following the shebang code, we must add in the “update” line. This line will check for any new software updates on Ubuntu. Press Enter in Nano to create a new line. Then, paste in the code below with Ctrl + Shift + V.
sudo apt update
Step 5: After adding the “update” line, it’s time to add in the “upgrade” line. ”
Upgrade” will install any pending software patches on your Ubuntu PC. Press Enter to create a new line. Then, paste in the code with Ctrl + Shift + V.
sudo apt upgrade -y
Step 6: Now that the “upgrade” line of code is in the easy update script, it is time to add the “autoremove” line. “Autoremove” will automatically uninstall and clean up any unwanted packages from the system.
To add the “autoremove” line to the script, press Enter, then paste the code below into the file with Ctrl + Shift + V.
sudo apt autoremove -y
Step 7: With “update,” “upgrade,” and “autoremove” added to the script, it is time to write a line of code that will automatically refresh and update all Snap packages on the system.
To add the Snap update line, press Enter. After that, paste the code below into the file with Ctrl + Shift + V.
sudo snap refresh
Step 8: After adding in the Snap update line, we must add in the Flatpak update line. To add it, press Enter on the keyboard to make a new line. Then, with Ctrl + Shift + V, paste the code below into the file.
Note: if you do not use Flatpaks on Ubuntu, feel free to skip this step.
sudo flatpak update -y
Step 9: With the Flatpak line added to the script, no more coding is required. Now we must save the “update” file to reflect the changes made. To save, press Ctrl + O.
After saving the “update” file, exit Nano with Ctrl + X.
Installing the easy update script
The easy update script is now written and ready to install. To install the script, we must place the file in the “/usr/bin/” directory. To place the file there, start by elevating your terminal session from a regular user to root using the sudo -s command.
sudo -s
Now that your terminal window has root access, you can place the easy update script inside of your “/usr/bin/” directory. To put the file there, use the mv command below.
mv update /usr/bin/
Now that the script is in the “/usr/bin/” directory, it is time to change the permissions of the file so that it can be run as a program on your Linux computer. To update the permissions of the file, use the chmod command.
chmod +x /usr/bin/update
Assuming the permissions of the “update” file have been changed, the script is ready to be used as a program in the command-line.
Using the easy update script
When the easy update script was written, it included many system operations to make updating much easier. Now that the script is ready to use, we can call all of those operations simply by running the update command in a terminal window.
update
Once the update command is run inside of a terminal window, you will be prompted to enter your user’s password. Do so. Soon after your Ubuntu packages will be upgraded, unwanted packages will be removed, and Snaps and Flatpaks will be upgraded automatically!
Making updates easier on Ubuntu with Software Center
Another way to make updating the Ubuntu operating system much easier is to use the Software Center, rather than the built-in update tool. Why? Not only can it take care of your Ubuntu package updates, but it also will upgrade Snap packages and other items as well.
To update with Ubuntu Software Center, do the following.
Step 1: Launch Ubuntu Software Center on your Ubuntu Linux desktop.
Step 2: Locate the “Updates” tab, and click on it with the mouse.
Step 3: Click the refresh button on the top left to check for software updates.
Step 4: Click the install button to get available updates.