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.
Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to perform related Linux commands queries.
In this context, we shall look into how to create aliases and use the alias command.
Linux alias syntax
Its syntax is given below:
$ alias [-p] [name[=value] ... ]
To list defined aliases, run the command:
How to create aliases ?
Here, you will learn 2 different types of aliases are temporary and permanent.
1. Creating temporary aliases
The command is:
$ alias name="value"
For example, We 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
If we want to create an alias for the command "cd /home" named "HH", We will run a demo:
How to remove aliases ?
The command to do this is:
$ unalias [alias name]
For example, if we want to remove the alias "update", the we can execute:
$ unalias update
[Need assistance in fixing Linux system firewall configuration ? We can help you. ]