Substituting the names of commands with custom names becomes important when you are dealing with long names of files and commands. The alias command allows us to perform this task. In this article, we will discuss some alias options and examples.
What is the alias command in Linux?
While executing commands, the alias command asks the shell to substitute one string with another string. When we often need to use a single large command several times, we construct an alias for it. Alias is a shortcut command that performs the same functions as if we typed the entire command. The syntax is:
alias [-p] [name[=value] ... ]
Temporary Alias
We can create a simple temporary alias where we simply substitute the target command with the word of our choice.
$ alias m=’mv’
$ alias m=’mv -i’
$alias file=’file.sh’
Permanent Alias
We need to add the alias to the configuration file: ~/.bashrc. Go down to the default system alias and add your aliases here just like you gave the command. The alias will be added in the next terminal season
Listing Alias
We can use simple alias command or alias - p to list the current alias in the system.
$ alias
$ alias -p
Removing an alias
We can use the below syntax to remove the given alias from the system
unalias [name]
Using - a options removes all aliases from the system
Conclusion
In this article, we went through various options related to the alias command in Linux. This command allows us to replace the name of the command with a custom name. It provides options like temporary addition, permanent addition, and removal of aliases in the system.
People are also reading:
Leave a Comment on this Post