码迷,mamicode.com
首页 > 其他好文 > 详细

alias命令

时间:2018-01-27 00:30:32      阅读:191      评论:0      收藏:0      [点我收藏+]

标签:cond   ash   file   vim   创建   logout   color   配置   alias命令   

alias 是创建别名的 用命令和组合,做成的新命令
[root@localhost ~]# 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‘
我们的cp 其实是cp -i 只不过用了alias别名
which 是用来查看一个文件存在的路径
但是查看文件的范围是有限制的
比如
[root@localhost ~]# which ifcongig-ens33
/usr/bin/which: no ifcongig-ens33 in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin)
这样是找不到的
是在[root@localhost ~]# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
这个范围路径里面找的 因为我们的网卡配置文件是在/etc 下的 所有是找不到的。
我们设置个别名
[root@localhost ~]# alias ygw=‘ls -lha‘
[root@localhost ~]# ygw
总用量 32K
dr-xr-x---. 2 root root 151 1月 10 00:37 .
dr-xr-xr-x. 17 root root 224 1月 26 03:35 ..
-rw-------. 1 root root 1.4K 1月 10 08:17 anaconda-ks.cfg
-rw-------. 1 root root 1.2K 1月 26 04:19 .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
-rw-r--r--. 1 root root 129 12月 29 2013 .tcshrc
-rw-------. 1 root root 1.1K 1月 10 00:37 .viminfo
这样是不是很清楚

取消别名 unalias
[root@localhost ~]# unalias ygw
[root@localhost ~]# ygw
-bash: ygw: 未找到命令
这样就取消了

alias命令

标签:cond   ash   file   vim   创建   logout   color   配置   alias命令   

原文地址:http://blog.51cto.com/12777709/2065680

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!