How To Use alias Command In Linux-Examples

alias command in Linux platform is used to tell the shell to replace one string with another string value while running commands. Using this command, it helps users to create an alias to a long-named command which is required to run multiple times. Doing so, it creates actually a shortcut command which functions in the same way as the one for which alias is created.

Syntax to use alias command in Linux

alias name="value"

Syntax to remove an alias in Linux

unalias [alias name]

Available options to use alias command in Linux

  • -p : prints all defined aliases
  • -help: displays help information regarding alias command

Examples to use alias command in Linux

1: creating an alias

alias CD="cd Desktop"

2: displaying help information

alias –help

Creating permanent aliases in Linux

In order to create and keep aliases permanently saved, you can place the created aliases in shell configuration file which can be one of the following:

  • Bash – ~/.bashrc
  • ZSH – ~/.zshrc
  • Fish – ~/.config/fish/config.fish