CentOS Debian Mint openSUSE Red Hat Ubuntu

alias Command in Linux

alias Command in Linux

Introduction

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.

Syntax

$ alias [-p] [name[=value] ... ]

To list defined aliases, run the command:

$ alias

Output:

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”:

$ update

Output:

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:

$ HH

Output:

How to remove aliases

$ unalias [alias name]

For example, I want to remove the alias “update” just now:

$ unalias update

Output:

Conclusion

In the above article, we guided you on how to create aliases and use the alias command in Linux.

Thanks for reading.

Similar Posts