Linux commands are cool and fun to work with. Be it ls (to list files) or cd (to change the directory), they are already short and precise. This is one of the reasons we love Linux. However, if you have to repeatedly type a set of commands or a long command with too many parameters, its not fun anymore. The Linux creators were caring enough to provide a solution for that too. The solution for such cases is Bash Shell Alias. A Bash Shell Alias(often called as a Bash Alias or simply an Alias ) is an alternate name, usually a short one, given to a command or a set of commands. This article shows how to get started with aliases and how to add them permanently in Ubuntu 20.04. It works for older versions too.

For example, I have to repeatedly type  cd /var/www/html in my day-to-day work. So I want to have a shortcut for it. I can create a custom command, say cdh, which is equivalent of the same. I can do so by typing the following on the terminal.

## Note: there should NOT be an space between cdh and 'cd /var/www/html'
$ alias cdh='cd /var/www/html'

How to add Bash Alias on ubuntu-20.04 - Steps by FoxbitsThe cdh command did not exist before. It is created and works after adding the alias.

If you are seeing this for the first time, I am sure you found it interesting and are excited to learn more about it. So, lets begin with the basics: the Syntax.

General Syntax:

##syntax for adding an alias to bash shell
alias MY_ALIAS_NAME='My_Command or A Set of Commands'

## To be more specific, here are a few samples
alias MY_ALIAS_NAME='My_Command'
alias MY_ALIAS_NAME='My_Command Argument_1, Argument_2 ...'
alias MY_ALIAS_NAME='My_Command_1; My_Command_2'
alias MY_ALIAS_NAME='/PATH/TO/A/SCRIPT'

#ubuntu 20.04 #bash #bash alias

What is Bash Alias and how to add one in Ubuntu 20.04
1.30 GEEK