一、普通用户
如果一些程序没有安装在系统默认的路径(ie /bin/, /usr/bin, /usr/local/bin/ )里面,这个时候普通用户想要调用这些命令,必须设定路径。方法很简单:以普通用户登录,然后在终端输入:
vi ~/.bash_profile
会出现如下的内容:
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
export PATH
此时,只要在export PATH前面加入自己的路径即可,例如我的修改后如下:
[yyc@localhost bin]$ cat ~/.bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:/sbin:/usr/sbin/:/usr/local/programs/crosstool/gcc-4.0.2-glibc-2.3.6/arm-linux-gnu/bin/
export PATH
二、超级用户
这里主要是一些用在系统管理上的命令,例如ifconfig, route等等, 他们位于/sbin, 或/usr/sbin/下。其实这些命令本身就没有任何问题,软件包早已安装完毕,路径设置也没有丝毫问题。而出现Command not found的原因在于:在终端使用su变成超级用户的时候没有将root的路径(环境)一起切换过来,从而导致身份虽然已经是root,但是工作的环境和路径依旧是普通用户的。这种问题的解决方法有两个,其一是按照(一)里面提到的,对普通用户的工作路径进行修改,但是这样比较麻烦。其二则简单的多,只要在使用su的时候在其后家上一个空格和”-“ ,即将su改为 su - 。这样就可以在成为root的同时将root的工作路径也一起切换过来了。如果你已经使用su变成了root, 那也没有关系,只要在输入一下su - 就好了。