How to Set Alias for commands in Linux terminal

We said how to Find your most Frequently used command in terminal in our last post. Now you once found that and if you feel a Single letter can replace a command in terminal, your productivity in terminal would be faster. Here in this post, we would tell you how to Set Alias (i.e assigning a new letter or a new term for the existing command, to simplify the work).

Step 1:- Choose a command

Decide or choose for which command you want to create an alias. For Example, You may use ‘ ls -l ‘ command to get the list of directories and files along with their permissions, user or group who owns it, Inode number of the file with date and time of creation of the file. So let us assume you need to create an alias for ” ls -l “.

ls command

Step 2:- Check for existing Aliases

Now that we have chosen ” ls -l ” command for creating a new alias for it. Before that we need to check if there already exist an alias for the command, so the we can avoid creating multiple aliases for the same command which may lead to confusion later. So, run the below command in terminal


Executing alias command would return the list of aliases which are existing by default along with the original non-aliased command.

alias command

Now you can see that ” ls -l –color=auto ” which is a command that we have described above that returns permissions, owner of file, and other information has already got the alias as “ ll “, so you can just usell ” instead of using “ ls -l –color=auto “.

Step 3:- Creating an alias for a new command

So based on the output of the Step 2, if there is no alias set for a command already, now you can set and use it for yourself. Let us create an alias for ” clear ” command although it has got shortcut keys as ” ctrl + l “. We are going to assign the single letter ‘ cfor the “clear” command. You can replace “c” with your desired alias. Example code below

alias c=’clear’

Now you can use ‘c’ instead of ‘clear‘ every-time.

alias clear command

Note:- while assigning alias for a command, there should not be any space between alias_name=”command’.

Step 4:- Deleting or Removing the alias

Now that we have a list of predefined alias commands as in the case of  “ ll ” and now we have created a new alias ” c “. Suppose if you want to delete the created alias or predefined alias and assign a new alias for the same command, you can do that by using the following

unalias alias_name

Eg:- unalias c – would delete the alias with name ‘c’ which we created in previous step. Similarly you can remove “ll” and set a new alias for ” ls -l –color=auto “.

unalias clear command

This is how you can set aliases for your most frequently used commands in terminal or for long commands and increase your speed of work.