2.5 alias命令

# alias //通過此命令查看系統中哪些命令有別名,可以設置指定的別名;
alias cp='cp -i'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias grep='grep --color=auto'
alias l.='ls -d .* --color=auto'
alias ll='ls -l --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'

有的命令是有alias的,有的命令是沒有的,如果想看哪個命令具體是否是組合命令,可以使用which來查看,也可以查看路徑,如下所示;
# which ll
alias ll='ls -l --color=auto'//它是使用命令加選項組成的組合命令
        /usr/bin/ls
# which ls
alias ls='ls --color=auto'
        /usr/bin/ls
# which man
/usr/bin/man

PATH 變量
# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin

自定義命令;
# alias abc=‘ls -lha’
# abc
總用量 28K
dr-xr-x---.  3 root root  147 6月   3 06:14 .
dr-xr-xr-x. 17 root root  224 6月   3 01:09 ..
-rw-------.  1 root root 1.6K 6月   3 01:11 anaconda-ks.cfg
-rw-------.  1 root root 2.3K 6月   3 18:56 .bash_history
-rw-r--r--.  1 root root   18 12月 29 2013 .bash_logout
-rw-r--r--.  1 root root  176 12月 29 2013 .bash_profile
-rw-r--r--.  1 root root  176 12月 29 2013 .bashrc
-rw-r--r--.  1 root root  100 12月 29 2013 .cshrc
drwx------.  2 root root   25 6月   3 06:14 .ssh
-rw-r--r--.  1 root root  129 12月 29 2013 .tcshrc
# which abc //查看abc自定義命令
alias abc='ls -lha'
        /usr/bin/ls
# unalias abc //取消abc自定義命令
# abc
-bash: abc: 未找到命令

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章