Linux aliases

Education is not limited to just classrooms. It can be gained anytime, anywhere... - Ravi Ranjan (M.Tech-NIT)

Linux aliases

Linux 'alias' command replaces one string from the shell with another string. It is a shell built-in command. It converts a complicated command into a simpler command or in other words, it creates a shortcut by replacing it with the simpler one.

Making 'alias' in command line creates a temporary 'alias'. Temporary aliases are only available until you exit the shell. To make permanent 'alias' store it in bash startup files.

Note: There will be no space on either side of (=) sign while typing 'alias' command. Quotes are necessary if there are more than one word in the string being aliased.

alias syntax:

  1. alias <newName>=<command>           (To create alias for commands)  
  2. alias <newName>=<'command arg1 arg2....'>   (To create alias for more than one argument)  
  3. alias <newName>=<'/home/sssit/path/...'>        (To create alias by a path) 

Creating an alias

Here, we are going to use following options for creating an alias.

  1. Creating alias for 'file' command as 'fi'
  2. Creating alias for 'ls-l' command as 'll'
  3. Creating alias with two arguments
  4. Creating alias for a path

1) Creating alias for 'file' command as 'fi'


alias <newName>=<command>


alias fi=file

Linux Aliases1

Look at the above snapshot, 'file' command is aliased as 'fi' through command "alias fi=file".

2) Creating alias for 'ls-l' command as 'll'


alias <newName>=<'command'> 


alias ll='ls -l' 

Linux Aliases2

Look at the above snapshot, 'ls -l' command is aliased as 'll' through command "alias ll='ls -l' ".

3) Creating alias with two arguments


  1. alias <newName>=<'command arg1 arg2'>  


alias both='ls sample example' 

Linux Aliases3

Look at the above snapshot, 'ls sample example' command is aliased as 'both' through command "alias both='ls sample example' ".

4) Creating alias for a path


alias <newName>=<'/home/sssit/path/...'>


alias path='cd /home/sssit/Downloads/sample'

Linux Aliases4

Look at the above snapshot, 'cd /home/sssit/Downloads/sample' command is aliased as 'path' through command "alias path='cd /home/sssit/Downloads/sample' ".

How to remove alias

With the help of 'unalias' command you can remove created alias.


unalias <createdAlias>


unalias c

Linux UnAliases5

Look at the above snapshot, alias 'c' work as 'cat' command. After removing 'c' by the command "unalias c" we got an error message.