Linux users often have to use the same command many times. This reduces productivity and makes users easily bored or distracted.
So the alias command is generated which helps us to create aliases for the commonly used commands. This command is like a shortcut to help reduce working time and make the working process more efficient.
We will guide you on how to create aliases and use the alias command as we go through below.
$ alias [-p] [name[=value] ... ]
To list defined aliases, run the command:
How to create aliases
2 types of aliases are temporary and permanent. We will guide you on how to make both.
1. Creating temporary aliases
$ alias name="value"
For example, I will create an alias for the command “sudo apt update” named “update”:
$ alias update="sudo apt update"
Then run the command “update”:
2. Creating permanent aliases
To keep the alias permanent between sessions, we have to save it in the shell configuration profile file.
Firstly, open the .bashrc file:
$ vim ~/.bashrc
Above, I want to create an alias for the command “cd /home” named “HH”.
We will run a demo:
How to remove aliases
$ unalias [alias name]
For example, I want to remove the alias “update” just now:
$ unalias update
In the above article, we guided you on how to create aliases and use the alias command in Linux.
Thanks for reading.
Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications including CCNA RS, SCP, and ACE. As an IT engineer and technical author, he writes for various websites.