Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

linux
communitycreator

What is the alias command in Linux?

abhilash

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

What is alias?

alias is a shortcut command that performs functions as if we typed the entire command.

Why do we use alias?

While executing commands, the alias command directs the shell to substitute one string with another string. Instead of typing the long command every time, we construct an alias/shortcut.


Permanent aliases can be created by adding the alias to the bashrc file for the bash shell, or the zshrc file for the zsh shell.

Syntax


alias shortcut_name = command

shortcut_name is the short form of the command you wish to use. When executing, shortcut_name will be replaced with the command.

For example:


alias gc="git commit -m 'First Commit'"

When the gc string is run in the terminal, git commit -m 'First Commit' is executed.


Running the alias command lists all the available aliases configured in the system.

Code

Terminal 1
Terminal

Explanation

In the above terminal, we define two aliases. One uses the echo command to print hello-educative, and the other prints the current date and time in the system.

RELATED TAGS

linux
communitycreator

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring