Creating Bash Alias with Linux alias command
alias command used to create aliases for other commands by providing alias names for long commands. For example, if you want to define the single letter "c" to be the command that
clear bash terminal, you can do it like this:
On most Linux distributions (Ubuntu, CentOS, etc.) the
bashrc file comes with a couple of useful aliases by default.
As you can see, grep is an alias to
grep --color=auto, which enables text output to display in color on the terminal.
Listing current aliases
To list the currently configured aliases for your bash shell, just type
alias with no other arguments.
The command will output a list of aliases that are already defined in your bash environment.
Setting new aliases
To understand how the Linux alias command works, we will create an alias for
pwd (Print working directory) command called "p".
We have created an alias called 'p' for the
pwd command. Now if we just run the "p" command we will get the current working directory.
The aliases you created in your terminal are not permanent and only available to your current shell. To make an alias permanent add them to the
If you want to remove an alias, use
unalias command followed by the name of the alias that you want to remove. For example:
Will remove the bash alias for the ls -alF command.