How to Create Alias of Command in Linux (alias command)
In Linux, if we want to create an
alias of any, we use the alias command.
The meaning of alias is "By the way". In the Linux/Unix operating system when we are using large commands multiple times so prevent writing large commands multiple times we create an
alias of those commands. The
alias command creates a shortcut of another large command and provides the same functionality.
The general syntax of the alias command.
alias [-p] [name[=value] ... ]
Types of Aliases
There are two types of aliases -
- Temporary Aliases
- Permanent Aliases
Temporary Aliases - This type of alias is as long as our current shell is active once we log out and come back later, these aliases are no longer. We can create temporary aliases using the below syntax as follows
$ alias alias_name = 'Custom Command'
Permanent Aliases - This type of alias is permanent. We can create permanent aliases by saving them in the user's shell configuration file.
Brief description of options available with the alias command.
||print all defined aliases in a reusable format
||display help information and exit
Example: Create an alias for printing the content of a file.
In this example, we create an alias for printing the content of a file that is available in another directory.
Example: print all defined aliases in a reusable format.
In this example, we can print all defined aliases in a reusable format using
Example: Removing an existing alias.
To remove existing
unalias command is used.
In this tutorial, we covered how to create an
alias of command and removing existing
alias in the Linux operating system.