Centos7_1708简版最小化安装,没有ifconfig命令解决办法

没有ifconfig命令解决办法(另外我百度到改环境变量的方法,有时间再试吧,这里是我用的解决办法)

用光驱配置yum源,安装net-tools这个软件包,以下是具体操作:

1.打开目录
[[email protected] /]#cd /etc/yum.repos.d
[[email protected] yum.repos.d]#ls
CentOS-Base.repo CentOS-CR.repo CentOS-Debuginfo.repo CentOS-fasttrack.repo CentOS-Media.repo CentOS-Sources.repo CentOS-Vault.repo

2.挂载光驱

[[email protected] yum.repos.d]#mount /dev/sr0 /media/
mount: /dev/sr0 is write-protected, mounting read-only

查看yum源配置文档
[[email protected] yum.repos.d]#cat CentOS-Media.repo

看是否和着一样,不一样用vi命令修改文档如下:(这是修改后的)
[c7-media]
name=CentOS-$releasever - Media
baseurl=file:///media/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
命令如下:
[[email protected] yum.repos.d]# vi CentOS-Media.repo

键盘 i 修改内容,改为上面内容后
键盘 ESC
输入 :wq 保存b并退出

然后重新挂载

[[email protected] yum.repos.d]#mount /dev/sr0 /media/
mount: /dev/sr0 is write-protected, mounting read-only

用yum list查看测试yum源是否存在问题(这个数字应该都不一样)
[[email protected] yum.repos.d]#yum list | wc -l
143

3.安装net-tools工具包

[[email protected] yum.repos.d]# yum install net-tools -y
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Resolving Dependencies
–> Running transaction check
—> Package net-tools.x86_64 0:2.0-0.17.20131004git.el7 will be installed
–> Finished Dependency Resolution
…………
Running transaction
Installing : net-tools-2.0-0.17.20131004git.el7.x86_64 1/1
Verifying : net-tools-2.0-0.17.20131004git.el7.x86_64 1/1
Installed:
net-tools.x86_64 0:2.0-0.17.20131004git.el7
Complete!

4.测试ifconfig命令:

Centos7_1708简版最小化安装,没有ifconfig命令解决办法

可能会发现没有红框内的:IP地址

5.让ip显示出来

[[email protected] yum.repos.d]#cd /etc/sysconfig/network-scripts

ifconfig命令后有个ens33(这个名字不确定,看自己是什么,我的是ens33

Centos7_1708简版最小化安装,没有ifconfig命令解决办法

然后找到ifcfg开头并以这个名字结尾的文件

[[email protected] network-scripts]#ls

Centos7_1708简版最小化安装,没有ifconfig命令解决办法

打开并编辑

[[email protected] network-scripts]#vi ifcfg-ens33

Centos7_1708简版最小化安装,没有ifconfig命令解决办法

键盘 i 编辑,
将 ONBOOT=no
改为 ONBOOT=yes
键盘 ESC
输入 :wq 保存并退出

然后重启
[[email protected] network-scripts]#service network restart

这时候再用命令ifconfig IP地址就显示出来了