How to Create Bash Aliases

Do you often find yourself typing a long command on the command line or searching the bash history for a previously typed command? If your answer to any of those questions is yes, then you will find bash aliases handy. Bash aliases allow you to set a memorable shortcut command for a longer command.

Bash aliases are essentially shortcuts that can save you from having to remember long commands and eliminate a great deal of typing when you are working on the command line. For example, you could set the alias tgz to be a shortcut for the [tar -xvfz](https://linuxize.com/post/how-to-create-and-extract-archives-using-the-tar-command-in-linux/) command.

This article explains how to create bash aliases so you can be more productive on the command line.

Creating Bash Aliases

Creating aliases in bash is very straight forward. The syntax is as follows:

alias alias_name="command_to_run"

Copy

An alias declaration starts with the alias keyword followed by the alias name, an equal sign and the command you want to run when you type the alias. The command needs to be enclosed in quotes and with no spacing around the equal sign. Each alias needs to be declared on a new line.

The ls command is probably one of the most used commands on the Linux command line. I usually use this command with the -la switch to list out all files and directories, including the hidden ones in long list format.

#bash #bash aliases #arguments

How to Create Bash Aliases
1.20 GEEK