alias

Shell aliases are simple way to create new commands. They overlap with shell functions, which are more versatile and should be preferred.

Create an alias:

# alias ls='ls --color=auto'

When typing “ls”, it will interpret it as typing “ls –color=auto”. Let’s say we don’t want to use alias, but also don’t want to remove it either. We can simply tell shell to omit alias by using four options:

  • Use command built-in. For example, typing “command ls” would omit ls alias.
  • Use full path of the command. For example, type /bin/ls.
  • Add \ anywhere in the command name. For example, type \ls or l\s and alias will be omitted.
  • Quote the command. For example, type “ls” or ‘ls’

Remove alias:

# alias now='date'
# now
Sun Jan 31 17:11 CET 2021
# unalias now
# now
- bash: now: command not found

List all aliases:

# alias -p

 

Leave a Reply