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: 未找到命令
这样就取消了

转载于:https://blog.51cto.com/12777709/2065680

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值