Config Server Firewall

Creating Bash Alias with Linux alias command

The bash 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:

alias c='clear'

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.

alias

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".

alias p='pwd'

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 ~/.bashrc file.

If you want to remove an alias, use unalias command followed by the name of the alias that you want to remove. For example:

unalias ll

Will remove the bash alias for the ls -alF command.