Alias commands in Linux are a great way to speed up your workflow. In this post, I will show you how to create Alias command in Linux.
What is an Alias command?
An Alias command is a shortcut to another command. Alias commands are useful when you need to write a long command multiple times. To save time, you can create a short Alias command to remove the need of writing the same lengthy command over and over again.
Examples of existing Alias commands on Linux
Out of the box, Linux comes with pre-created Alias commands. You likely use these commands regularly without knowing it.
From the terminal, type alias and hit ENTER. This will print all the Alias commands on your system.
As you can see, there are already a number of Alias commands on your system.
Create an Alias command on Linux
Open a new terminal. You will already be in the user’s home directory.
Form the user’s home directory, open the .bashrc file in an editor.
At the bottom of the file, add the following:
alias docs='cd Documents'
Save and exit the file.
The new Alias command will change our directory to the user’s Documents directory when executing the alias ‘docs‘.
How to use Alias commands in Linux
Now we have created our Alias command, close the terminal and re-open a new terminal window.
To execute the new Alias command, simply type ‘docs‘
Alias commands in Linux are a great way to speed up your workflow when need to execute repetitive commands.
I use Alias commands daily to move around the filesystem when configuring new sites.