The alias Command in Linux

The alias command in Linux is used to make a shortcut or an alternative name for an existing command. So instead of re-typing the same commands with all the options over and over again, you can create a shorthand for the same and make it simpler to use in the future.

How to use the alias command in Linux?

The alias command is very simple and straightforward. The basic syntax is alias customName=”actual command”.

Suppose I use the head command with multiple options like here: head -n 3 -v. I don’t want to keep typing these options every time I want to run this command. So I will create an alias.

root@HowLinux:~# alias head3="head -v -n3"
Alias Command In Linux
Alias Command In Linux
Alias Command Executed Example
Alias Command in Unix Executed Example

Listing all the existing aliases

If you want to find out which aliases are already present for the system, you can run the alias command by itself or with the -p and you’ll see all the aliases.

root@HowLinux:~# alias
root@HowLinux:~# alias -p

Both the commands above will give you the same output since the alias command has only one option, which is the -p option.

Alias Command List Aliases
Alias Command – List Aliases

How to make the alias command permanent?

The aliases you define with the alias command in Linux directly will continue to stay on the system until you restart or log out of the user account. If you want an alias to be present every time you log in to the system, you need to set it up in the .bashrc file. Let’s take a look at how we can make this happen.

The .bashrc file is usually present in the home (~) directory. If not, you can create a file with that name. Note that there’s a period before the filename to make it a hidden file.

root@HowLinux:~# nano ~/.bashrc

GNU nano 2.9.3             /root/.bashrc         Modified
alias head3="head -v -n3"
Editing Bashrc For Alias Command Nano
Editing Bashrc For Alias Command Nano
Editing Bashrc For Alias Command
Editing Bashrc For Alias Command

Enter a line in the file, in the same way, you’d enter the alias command to create an alias in the terminal. The .bashrc file runs all the commands listed in the file when you first log in. So any command that is in the file, will be executed as if it was run on the terminal.


Well, that’s it for the alias command. The sole purpose of the alias command in Linux is to make life easier for terminal users. There are many commands that we use on a daily basis and have a ton of options that go along with them. Creating multiple aliases of the commands that you use regularly will be a great way to make using the terminal very efficient.