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: 未找到命令

猜你喜欢

转载自blog.51cto.com/13776311/2126558
2.5