Skip to content

Setting Up Aliases

What are Aliases?

Aliases are ways that someone can create their own shorthands for commands. For example, if I wanted to create a command called hello that would print "Hello world!" to the console every time I wrote the hello command into the console, I could create an alias to do this.

Many common commands such as ll or la are actually aliases, typically written in a file such as .bashrc

Creating an Alias

Just like with modifying the PATH variable, there are various spots in which an alias can be created.

Similarly to editing the PATH variable, I'll go over how to create an alias in a shell session and using .bashrc.

Creating an Alias in a shell session

Using the example of the hello command that I talked about earlier, I created this alias by writing the following command into bash

console
alias hello='echo "Hello, world!"'

Then I ran it to test that it works

Testing alias

Creating an Alias in .bashrc

Similarly to modifiying the PATH variable, to create an alias in .bashrc, the command that I ran in the shell session can simply be copied into .bashrc