alias (Command Shortcuts)
The alias command allows you to create shortcuts for long or frequently used commands. It helps to simplify your workflow, reduce typing errors, and customize your terminal environment to your liking.
1. Basic Usage
alias name='command'
2. Key Commands
| Action | Command | Description |
|---|---|---|
| List Aliases | alias |
Prints all aliases defined in the current session. |
| Remove Alias | unalias name |
Removes a specific alias. |
| Temporary Bypass | \command |
If you have an alias, using a backslash runs the original command. |
3. Practical Power-User Examples
① Quick Navigation
alias ..='cd ..'
alias ...='cd ../..'
alias .3='cd ../../..'
② Git Shortcuts (If git is installed)
alias gs='git status'
alias ga='git add .'
alias gc='git commit -m'
③ Docker Cleanup
alias dprune='docker system prune -a'
4. [Tip] Making Aliases Persistent
To keep your aliases after restarting the terminal, add them to your shell configuration file:
* For Bash: ~/.bashrc
* For Zsh: ~/.zshrc
After editing, run source ~/.bashrc to apply the changes immediately.