Linux终端下使用ifconfig命令出错“bash ifconfig command not found “解决方法
⏹平台信息:FAQ适用于linux环境。
⏹适用对象:爱数技术人员/客户/代理商技术人员。
⏹文档类型:FAQ。
问题描述
打开linux终端,输入ifconfig,显示ifconfig:command not found ,su root,还是不可以。
如下图所示:
分析问题
主要是一些用在系统管理上的命令,例如ifconfig, route等等,他们位于/sbin, 或/usr/sbin/下。
其实这些命令本身就没有任何问题,软件包早已安装完毕,路径设置也没有丝毫问题。
而出现Command not found的原因在于:在终端使用su变成超级用户的时候没有将root的路径(环境)一起切换过来,从而导致身份虽然已经是root,但是工作的环境和路径依旧是普通用户的。
解决方案
方案一:最直接的办法是使用su - ,root的路径会一起跟着变过来,就可以运用ifconfig进行网络配置等操作。
如下图所示:
方案二:在root用户下按照下面的操作进行修改文件,重新启动或者注销系统,再输入ifconfig就可以直接配置网络了。
操作如下:
[oracle@rhel4ora10g ~]$ su
[root@rhel4ora10g oracle]# vi /etc/profile
把下面if语句注释掉:
#path Manipulation
if [`id -u` = 0]; then
pathmunge /sbin
pathmunge /usr/sbin
pathmunge /usr/local/sbin
fi
修改为:
#path Manipulation
#if [`id -u` = 0]; then
pathmunge /sbin
pathmunge /usr/sbin
pathmunge /usr/local/sbin
#fi。