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.
Creating ephemeral aliases:
Ephemeral aliases only exist in the current shell session and vanish when the terminal closes.
- Open a terminal on a Linux or Unix-like system.
- Assign a name to a command.
$ alias l='ls --all --human-readable --color=auto'
- List all aliases to confirm.
$ alias alias egrep='egrep --color=auto' alias fgrep='fgrep --color=auto' alias grep='grep --color=auto' alias l='ls --all --human-readable --color=auto'
- Remove an alias if necessary.
$ unalias l
Temporary aliases are useful for testing or handling one-time shortcuts without making permanent changes.
Creating persistent aliases:
Persistent aliases survive across Bash sessions by storing definitions in user configuration files like ~/.bashrc.
- Open the ~/.bashrc file in a text editor.
$ nano ~/.bashrc
- Scroll to an appropriate section and add an alias definition.
alias ll='ls --long --human-readable --color=auto'
- Save the file and exit the editor.
- Reload the shell configuration to apply the changes immediately.
$ source ~/.bashrc
- Verify the new alias.
$ 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.

Mohd Shakir Zakaria is a cloud architect with deep roots in software development and open-source advocacy. Certified in AWS, Red Hat, VMware, ITIL, and Linux, he specializes in designing and managing robust cloud and on-premises infrastructures.
Comment anonymously. Login not required.