alias command in Linux, How to create and use alias command with examples

alias command is mainly used to define a new command (a shortcut name) for a single big command. It helps us to avoid repetitive long typing of commands.

  • The shortcut name can be used as a substitute for a single big command because shortcut name will have same functionality as if we write the big command.
  • It helps us to save a lot of time when we have to write big command frequently.
  • An alias doesn’t replace itself.

Syntax for alias command

  • There must be no spaces before or after the equals sign in the alias command.
alias [option] Name='value'

To display all defined alias use the command alias -p. We can also use alias to display all defined alias.

alias -p

alias -p command in linux


Types of alias in Linux

We can create two types of alias in Linux

  1. Temporary alias
  2. Permanent alias

Creating Temporary alias


alias command in Linux with example


Creating Permanent alias

unalias the alias command

remove any specific alias

To delete any specific alias use commandunalias alias_name Don’t forget to replace alias_name with your alias name

unalias alias_name

remove all aliases

To delete all aliases  use the command unalias -a

unalias -a