![Forrest logo](/images/logo.png)
alias:tldr:72487
The 'alias' command is used in command-line interfaces (such as Unix-like systems) to create a custom shorthand or a substitute command for a longer or more complex command.
When you define an alias, you assign a name to a command or set of commands. Then, you can use that name to execute the associated command(s) instead of typing out the entire command each time. It helps to simplify and speed up command-line usage by creating shortcuts.
Here's the general syntax to create an alias:
alias [alias_name]='[command]'
For example, let's say you frequently use the command 'ls -l' to list the contents of a directory in a long format. To create an alias called 'll' for this command, you would use:
alias ll='ls -l'
Now, whenever you enter 'll' in the command line and press enter, it will execute 'ls -l' instead. This saves you from typing three characters every time you want to list the directory contents in a long format.
Aliases are stored in memory and do not persist after you close the command-line session. To make them permanent, you can add the alias command to a configuration file (e.g., .bashrc or .bash_profile) in your home directory.