Javatpoint Logo
Javatpoint Logo

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:


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'

Syntax:

Example:

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'

Syntax:

Example:

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

Syntax:

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

Syntax:

Example:

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.

Syntax:

Example:

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.

Next TopicLinux Arguments





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA