[[email protected] ~]# alias
#查詢命令別名
[[email protected] ~] # alias 別名='原命令'
#設定命令別名
[[email protected] ~]# alias
#查詢系統中已經定義好的別名
alias cp='cp -i'
alias l='ls -d .* --color=auto'
alias ll='ls -1 --color=auto'
alias ls='ls --color=auto'
alias mv='mv -i'
alias rm='rm -i'
alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
[[email protected] ~]# alias vi='vim' #定義vim命令的別名是vi
[[email protected] ~]# alias
#重新查詢別名
alias cp='cp -i'
alias l.='ls -d .* --color=auto'
alias ll='ls -1 --color=auto'
alias ls='ls --color=auto'
alias mv='mv -i'
alias rm='rm -i'
alias vi='vim'
#別名已經生效
alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
[[email protected] ~]# alias sto='/usr/local/apache2/bin/apachectl stop'
[[email protected] ~]# alias sta='/usr/local/apache2/bin/ apachectl start'
[[email protected] ~】# vi /root/.bashrc
# .bashrc
# User specific aliases and functions
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
alias vi='vim'
alias sto='/usr/local/apache2/bin/apachectl stop' alias sta='/usr/local/apache2/bin/apachectl start'
#Source global definitions
if [ -f /etc/bashrc ];then
./etc/bashrc
fi
[[email protected] ~]# unalias vi
當然,如果確定要刪除別名,則也要刪除環境變數組態檔中的相關項才可以。