23 Handy Bash Shell Aliases For Unix, Linux, and Mac OS X

What is an Alias?

If you find yourself typing the same command over and over again, you can create a shortcut for it called an alias. An alias can be thought of as a text expander. Creating aliases for commands that are really long is also a common practice. For example, if you type ls -l frequently, you may want to abbreviate it to ll. As a matter of fact, this alias often comes predefined on many Linux distributions.

The alias Command

alias [name[=value]]

The alias command lists or create aliases. If no arguments are provided the current list of aliases is displayed. Use name=value to create a new alias.

Colorize Output

# Colordiff may not be installed by default.  (sudo apt-get -y colordiff to install on Ubuntu systems.)
alias diff='colordiff'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias grep='grep --color=auto'
alias ls='ls --color=auto'

Changing Directories

alias ..='cd ..'
alias ...='cd ../../../'
alias ....='cd ../../../../'

Prettify the Output of Various Commands

# Use the column command to create pretty tables. 
alias ct='column -t'
alias dfc='df -hPT | column -t' 
alias mount='mount | column -t'

 Date and Time Aliases

alias d='date +%F'
alias now='date +"%T"'
alias nowtime=now
alias nowdate='date +"%m-%d-%Y"'

Confirmation When Copying, Linking, or Deleting

alias cp='cp -i'
alias ln='ln -i'
alias mv='mv -i'

System Updates

# Debian / Ubuntu:
alias apt-get="sudo apt-get"
alias updatey="sudo apt-get -y"
alias update='sudo apt-get update && sudo apt-get upgrade'
 # RHEL, CentOS, Fedora
alias update='yum update'
alias updatey='yum -y update'
alias