bash: ifconfig: command not found 解决办法(转)

用虚拟机时,遇到了这个问题,所以搜了一下,顺便把解决方法记下来。

原本使用ifconfig 可以使用,今天是怎么了,可能安装软件修改了,百度~~ 
[oracle@localhost /]$ ifconfig 
提示:“bash: ifconfig: command not found” 

于是我切换到root用户下 
[root@localhost /]$ ifconfig 
依然提示:“bash: ifconfig: command not found” 

分析问题 
1.whereis ifconfig 看一下这个命令在哪个目录下 

2.echo $PATH 看一下该目录是否在路经下,注意lunux下是完全区分大小写的,所以不要忽略这点 

3.执行命令,需要指定路径或者把目录加入PATH中 

4.于是可以这样访问 
方法一:[root@localhost sbin]$ /sbin/ifconfig 就可以出现使用了 
方法二:[root@localhost sbin]$ export PATH=$PATH:/sbin ,这样设置后,下次就可以直接访问了,免处第一种的麻烦,如: 
[root@localhost /]$ ifconfig 

方法三:修改/etc/profile文件,注释掉if语句即可 
把下面的if语句注释掉: 
# Path manipulation 
if [ "$EUID" = "0" ]; then 
pathmunge /sbin 
pathmunge /usr/sbin 
pathmunge /usr/local/sbin 
fi 
修改为 
# Path manipulation 
# if [ "$EUID" = "0" ]; then 
pathmunge /sbin 
pathmunge /usr/sbin 
pathmunge /usr/local/sbin 
#fi 

注:不光是ifconfig命令出现“bash: ifconfig: command not found”,原因非root用户的path中没有/sbin/ifconfig 
,其它的命令也可以出现这种情况,解决的方法是一样的。

转载于:https://www.cnblogs.com/Chen-Arvin/archive/2012/11/29/2795248.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值