alias命令

114 阅读1分钟

文章目录

1、which ls:查看文件别名
[root@yang-1 ~]# which ls     //查看文件别名
alias ls='ls --color=auto'     //命令加选项这样的组合形成的一个新的命令
	/usr/bin/ls     //绝对路径
[root@yang-1 ~]# which ll
alias ll='ls -l --color=auto'
	/usr/bin/ls
[root@yang-1 ~]# which man
/usr/bin/man
[root@yang-1 ~]# which yum
/usr/bin/yum
[root@yang-1 ~]# 
2、alisa:查看系统下命令的别名
[root@yang-1 ~]# 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'
[root@yang-1 ~]# 
3、echo $PATH:变量
[root@yang-1 ~]# echo $PATH     //变量
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin     //一系列路径
4、which mv:查看一个命令所在位置
[root@yang-1 ~]# which mv     //查看一个命令所在位置
alias mv='mv -i'
	/usr/bin/mv
5、alias yang=‘ls -lha’ :创建命令别名
[root@yang-1 ~]# alias yang='ls -lha'     //创建命令别名
[root@yang-1 ~]# yang     //测试别名是否生效
总用量 60K
dr-xr-x---.  3 root root  218 9月  20 21:06 .
dr-xr-xr-x. 17 root root  224 921 22:00 ..
-rw-------.  1 root root 1.4K 9月  18 06:27 anaconda-ks.cfg
-rw-------.  1 root root 3.5K 9月  23 23:49 .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   58 9月  18 22:46 dnfaifonvvreigh
-rw-------.  1 root root   35 9月  18 22:46 .lesshst
drwx------.  2 root root   80 9月  22 20:55 .ssh
-rw-------.  1 root root  12K 9月  20 20:43 .ssh.swo
-rw-------.  1 root root  12K 9月  20 20:42 .ssh.swp
-rw-r--r--.  1 root root  129 12月 29 2013 .tcshrc
[root@yang-1 ~]# which yang     //查看别名所在路径
alias yang='ls -lha'
	/usr/bin/ls
[root@yang-1 ~]# 
6、unalias yang :删除命令别名
[root@yang-1 ~]# unalias yang     //删除命令别名
[root@yang-1 ~]# yang     //测试别名是否删除
-bash: yang: 未找到命令
[root@yang-1 ~]#