Bash supports short command replacements called aliases. They streamline frequently used commands, reduce repetitive typing, and maintain consistent command usage across sessions. Many Linux environments include default aliases that demonstrate how quick shortcuts can improve efficiency.
Aliases can be temporary or persistently defined in user configuration files. By default, ephemeral aliases expire when the current shell session ends. Permanent alias definitions are typically placed in the ~/.bashrc file or other startup scripts to automatically load each time Bash starts.
Creation and management of aliases require minimal syntax. A single keyword, alias, assigns a new name to an existing command, optionally with flags or parameters. Additional commands like unalias remove or modify existing aliases if needed. There is no limit to how many aliases can be defined.
Ephemeral aliases only exist in the current shell session and vanish when the terminal closes.
$ alias l='ls --all --human-readable --color=auto'
$ alias alias egrep='egrep --color=auto' alias fgrep='fgrep --color=auto' alias grep='grep --color=auto' alias l='ls --all --human-readable --color=auto'
$ unalias l
Temporary aliases are useful for testing or handling one-time shortcuts without making permanent changes.
Persistent aliases survive across Bash sessions by storing definitions in user configuration files like ~/.bashrc.
$ nano ~/.bashrc
alias ll='ls --long --human-readable --color=auto'
$ source ~/.bashrc
$ alias alias ll='ls --long --human-readable --color=auto'
Exercise caution when defining aliases that override existing commands or names to prevent unintended system behavior.