alias(1)
Create or display shell aliases, which are custom shortcuts for commands.
Synopsis
alias [-p] [name[=value] ...]Description
The alias command defines or displays aliases—short names that expand to longer command strings when executed. Aliases are useful for creating convenient shortcuts for frequently used commands, especially those with many options.
When called without arguments, alias prints all currently defined aliases. When given a name and value, it creates a new alias. Aliases are typically session-specific and defined in shell startup files like ~/.bashrc or ~/.zshrc to persist across sessions.
Common options
| Flag | What it does |
|---|---|
-p | Print all defined aliases in a format that can be reused as input |
Examples
Display all currently defined aliases in the shell
aliasCreate an alias 'll' that runs 'ls -lh' to list files in long format with human-readable sizes
alias ll='ls -lh'Create an alias so grep always colorizes matching text in output
alias grep='grep --color=auto'Create an alias to correct the common typo of typing 'cd..' instead of 'cd ..'
alias cd..='cd ..'Print all aliases and filter to show only the 'll' alias definition
alias -p | grep llRemove the 'll' alias from the current shell session
unalias llCreate a safety alias for rm that prompts for confirmation before deleting each file
alias rm='rm -i'