which:查找某个命令的绝对路径。bash
#[root@localhost~]# which lsspa
alias ls='ls --color=auto'ip
/bin/lsit
alias:为命令提供别名,通意小名。能够使较长的命令简化。变量
[root@localhost~]# alias配置
#显示当前全部别名network
[root@localhost~]# alias vieth='vi /etc/sysconfig/network-scripts/ifcfg-eh0'command
#配置别名,以后vith命令即至关于‘’中命令。环境变量
[root@localhost~]# which vieth文件
alias vieth='vi /etc/sysconfig/network-scripts/ifcfg-eh0'
/bin/vi
若是想取消别名,只须要unalias vieth便可。
环境变量PATH:将命令路径加入$PATH中后,可直接使用命令,而不须要使用绝对路径。
[root@localhost~]# echo $PATH
#打印当前环境变量
/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
若是将ls移到/root/中的话,没法执行,提示"command not found"。
[root@localhost~]# mv /bin/ls /root/
[root@localhost~]# ls
-bash:/bin/ls:没有那个文件或目录
解决这个问题,3种办法:
一、将ls移回原位置。
[root@localhost~]# mv /root/ls /bin/
[root@localhost~]# ls
anaconda-ks.cfg install.log install.log.syslog
二、将/root这个路径加入$PATH当中。
[root@localhost~]#PATH=$PATH:/root
[root@localhost~]# echo $PATH
/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/root
[root@localhost~]# ls
anaconda-ks.cfg install.log install.log.syslog ls
三、使用绝对路径。
[root@localhost~]# /root/ls
anaconda-ks.cfg install.log install.log.syslog ls