Every day, one of the first things I do on my computer is run an update/upgrade. That process normally consists of three commands, which are:
That's not too much to type. The only problem is that I have to wait for theprevious command to stop before I can type the next. Or, I can combine them into one long command like this:
sudo apt-get update && sudo apt-get upgrade -y && sudo snap refresh
That combination means I don't have to wait for one command to complete before typing the next.
Also: How to choose the right Linux desktop distribution for you
Even so, that's a long command to type every morning.
Fortunately, this is Linux, so there's always a way to make things easier -- and in this case, it's via aliases.
Simply put, an alias allows you to configure a single word to serve as an alias for a command. So, instead of typing:
sudo apt-get update && sudo apt-get upgrade -y && sudo snap refresh
AllI have to do is type:
update
I'm immediately prompted for my sudo password and all three commands will run (one after another), to take care of the update/upgrade/refresh process for me.
Also: 8 things you can do with Linux that you can't do with MacOS or Windows
Let me show you how. It's quite easy and can make your Linux-using life considerably more efficient.
What you'll need: The only thing you'll need for this process is a running instance of Linux. It doesn't matter what distribution you use because aliases are available to all of them, from the user-friendly Ubuntu all the way to the fiercely complicated Gentoo. I'll demonstrate on my current go-to Linux distribution, Ubuntu Budgie.
The first thing to do is log in to your Linux desktop or server and open a terminal window.
The file that houses aliases is called .bashrc. The .bashrc file is a script that holds a number of commands and environmental settings that are executed when a user logs into their Linux account. Within that file, there's a section that includes a number of pre-defined aliases (such asll for the ls -alFcommand).
Also: The best Linux laptops for everyone
We're going to create an alias for the upgrade process I outlined above. Keep in mind that the distribution you use will dictate the command you run (for example, dnf in place of apt for Fedora Linux).
Open the .bashrc file with the command:
nano ~/.bashrc
Scroll down until you see the section that starts with#some more ls aliases. We're going to add our new alias below that section.
Also: Ubuntu Cinnamon makes switching from Windows to Linux as painless as possible
First, add a comment, so you know what the alias is that we're creating. That comment could be something like this:
#update alias
Below, we'll add our alias, which looks like this:
alias update='sudo apt-get update && sudo apt-get upgrade -y && sudo snap refresh'
The breakdown is simple:
alias SHORTCUT='COMMAND'
The word alias informs bash that what follows is an alias. SHORTCUT is the word you want to use for the alias as a shortcut for the command that follows. COMMAND is the actual command you want to use for the alias, wrapped in single quotes.
Save and close the file.
Don't close the current terminal window. Instead, open a second terminal (or a new tab in the current window) and type the shortcut we used for the alias (in this case,update). The update command should run. If it does, congratulations, you've just created your first Linux alias.
Also: The most important reason you should be using Linux at home
Remember, however, that if you're not using an Ubuntu-based distribution, the command you run for the alias will be different. And if your distribution doesn't use Snap packages, you'll want to either remove the Snap bit or replace it with the Flatpak refresh command.