alias command

The alias command can be useful if you want to create a 'shortcut' to a command.
The format is alias name='command'

> alias home='cd /home/dave/public_html'

This will create an alias called home which will put you in the /home/dave/public_html directory whenever you type home at the command prompt. You can alias any command you want, and include options for the command.

> alias list='ls -la'

This will create an alias called list, which will use the ls command to print a long-style listing of all files in the current directory (the -l gives a long-style list, and the -a shows all files - including hidden files).
(Find out more about the ls command)

To see a list of aliases set up on your linux box, just type alias at the prompt.

> alias
alias attrib='chmod'
alias chdir='cd'
alias copy='cp'
alias cp='cp -i'
alias d='dir'
alias del='rm'
alias deltree='rm -r'
alias dir='/bin/ls $LS_OPTIONS --format=vertical'
alias edit='pico'
alias ff='whereis'
alias ls='/bin/ls $LS_OPTIONS'
alias mem='top'
alias move='mv'
alias mv='mv -i'
alias pico='pico -w -z'
alias rm='rm -i'
alias search='grep'
alias v='vdir'
alias vdir='/bin/ls $LS_OPTIONS --format=long'
alias which='type -path'
alias wtf='watch -n 1 w -hs'
alias wth='ps -uxa | more'
>

You can see there are a few already set up on a default Redhat 9 installation.

To remove an alias, use the unalias command.

Back to index

Subscribe to us on YouTube