Alias Facts
Aliases in Linux
Definition
An alias is a shortcut stored in memory that runs a command on your Linux system.
Most distributions include predefined aliases created at system startup.
Custom aliases can be defined in the shell prompt.
Persistence of Aliases
Aliases defined with the
aliascommand are not persistent across reboots.To make aliases persistent, add definitions to:
/etc/profile~/.bashrc
Displaying Defined Aliases
Use the command
aliasto display currently defined aliases.Example output:
alias egrep='egrep --color=auto'alias fgrep='fgrep --color=auto'alias grep='grep --color=auto'alias ll='ls -l --color=auto'alias ls='ls --color=auto'
Creating and Removing Aliases
Creating Aliases
Command format:
alias [name='command']Example:
alias securebackup='cp ./*.* /dev/st0/*.*; shred -fuvz ./*'Description: Copies all files in the specified directory to a tape backup device and shreds the original files.
A single alias can run multiple commands; encapsulate commands with quotation marks or apostrophes.
Removing Aliases
Command format:
unalias [name]Example:
unalias securebackupDescription: Removes the specified alias.
Example:
unalias forcelogoutto delete theforcelogoutalias.