linux安装报错之:ifconfig command not found解决

问题描述:

用虚拟机VMware安装linux系统(镜像文件是从官网下载的CentOS-7.0-1406-x86_64-DVD.iso),

在安装完成之后,输入ifconfig命令报错:ifconfig command not found

 

解决思路:

1 确定是否是没有安装ifconfig,如果没有,添加上去

2 确定是否是没有添加到环境变量上,如果没有,添加上去

 

解决方法:

复制代码
首先判断一下是不是缺少了ifconfig,它是在/sbin目录下的




[root@localhost ~]# cd /sbin
[root@localhost sbin]# ls

查看一下是否有 ifconfig


没有 ifconfig 的话安装 net-tools package


[root@localhost sbin]# sudo yum install net-tools
复制代码

 

参考:https://blog.csdn.net/dandelion_drq/article/details/53503487

 

当然,如果指定目录下已经存在ifconfig,也有可能是其它问题导致,比如环境变量没有添加:

复制代码
原本使用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

,其它的命令也可以出现这种情况,解决的方法是一样的。 
 

---------------------

本文来自 xu1314 的CSDN 博客 ,全文地址请点击:https://blog.csdn.net/xu1314/article/details/6951762?utm_source=copy 
复制代码

 

posted @   WhoKnows1  阅读(54379)  评论(0编辑  收藏  举报
编辑推荐:
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
阅读排行:
· 分享 3 个 .NET 开源的文件压缩处理库,助力快速实现文件压缩解压功能!
· Ollama——大语言模型本地部署的极速利器
· 使用C#创建一个MCP客户端
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· Windows编程----内核对象竟然如此简单?
点击右上角即可分享
微信分享提示