Introduction to Unix

../_images/ksuPoly1.jpg ../_images/UNIX_blocks1.jpeg

5.6. alias

Linux for Programmers and Users, Sections 6.4.1

alias

An alias is a short cut command to a longer command. Users may type the alias name to run the longer command with less typing. Without arguments, alias prints a list of defined aliases. A new alias is defined by assigning a string with the command to a name. Alias are often set in the ~/.bashrc file.

SYNOPSIS
alias [-p] [name[=string]]

OPTIONS:

-p

Display all aliases in a format suitable for input to the shell.

Examples:

alias c='clear'
alias lf='/bin/ls --color -CF'
alias ll='ls -l --color=auto'
alias ls='ls --color=auto'
alias r='fc -s'
alias vi='vim'

Note

If a user wishes to run a command without the alias definition, they can type a \ character in front of the command. For example, with the above alias definitions, the ls command displays as if ls --color=auto were typed. To see ls without the color option, type \ls.

unalias

Remove defined aliases

SYNOPSIS
unalias [-a] name [name ...]

OPTIONS:

-a

Remove all aliases

5.7. Auto Completion

Another typing short-cut is BASH’s auto completion feature. BASH can complete a filename, command name, username or shell variable that you have begun to type if enough has been typed to uniquely identify it. While typing on the command line, press TAB to see if BASH can complete the word you are typing. If it can not identify a completion, nothing appears on the command line, but by pressing TAB a second time, a list of possible matches is displayed.