If you’ve been using Ubuntu or any other kind of Linux, you’ve probably wanted to update your computer, or at least some packages that you’ve installed. In this article, I’ll be showing you a cool trick for updating your computer. After you read this article, you might think that this trick is really obvious, but I figured I’d share this in case some people haven’t thought of it yet.
You may know about the Software Updater application on Ubuntu, which checks if your comptuer has any more updates available and then installs them. I will be showing you a cool terminal trick that updates packages, upgrades them, autoremoves packages, and updates snap applications, and more. This is a really simple trick, but I use it all the time and it proves to be useful.
Most of the time I prefer terminal over GUI for things like this. When I update the computer, I usually enter something like this:
sudo apt update && sudo apt upgrade && sudo apt autoremove
…and then I do other things with updating Snapcraft applications (Use this video if you want to know about Snapcraft: https://youtu.be/nt-tI0RJS_c).
I’ve installed a GNOME Shell Extension that tells me how many apt updates there are (Called Apt Indicator). If you want to know how to install GNOME Extensions, use my post on that, or use this video: https://youtu.be/0VEz-cfMBXA. When I see a number on the indicator in the system top bar, I know that there are some apt packages that need to be upgraded, and I usually run something like “sudo apt upgrade.” But I also want to know when I have Snapcraft updates, or any other kind of updates. With this simple trick, all I have to type in the terminal is:
How to Do It
Open the configuration file for your shell (most likely ~/.bashrc, unless you use a different shell). All you have to do is go to the very bottom of the file and type the following code:
alias update='sudo apt update && sudo apt upgrade && sudo snap refresh && sudo apt autoremove'
This will create an alias every time you start a new terminal session that tells your computer to do the following:
- Run sudo apt update
- Upgrade your apt packages
- Update Snapcraft packages
- Remove any unused packages
You can add any other commands to this alias.
So now all you have to do is type “update” whenever you want to update your system! Thanks for reading this article. If you have any questions, leave them in the comments below.