CentOS7学习(1)

CentOS7 最小化安装之后,无法使用yum和ifconfig的问题

yum的问题

1.首先,需要确定切换到的用户是否为root用户,使用su切换
2.其次,再使用

cd /etc/sysconfig/network-scripts/

切换到相应的目录中,使用ls -a命令查看如下的目录,
这里写图片描述

找到网卡的配置文件(centos7修改了网卡的命名规则,不再是我们熟悉的eth0了,而是ifcfg-eno+一串数字),例如我的就是ifcfg-eno16777736
3.使用vi 编辑 ifcfg-eno16777736
将如下的字符更改为:yes
这里写图片描述
4.重启网卡

service network restart 

这里写图片描述

5.就可以使用yum了
这里写图片描述

ifconfig的问题

1.首先需要搞清楚CentOS 7最小化系统,使用“ip addr”和“ip link”命令来查找网卡详情。要知道统计数据,可以使用“ip -s link”。

要查看网卡细节,输入以下命令:

ip addr

输出样例


1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eno16777736: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:0c:29:af:e9:5d brd ff:ff:ff:ff:ff:ff
    inet 192.168.79.128/24 brd 192.168.79.255 scope global dynamic eno16777736
       valid_lft 1538sec preferred_lft 1538sec
    inet6 fe80::20c:29ff:feaf:e95d/64 scope link
       valid_lft forever preferred_lft forever

这里写图片描述

或者输入如下命令:

ip link

输出样例:


1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eno16777736: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000
    link/ether 00:0c:29:af:e9:5d brd ff:ff:ff:ff:ff:ff

这里写图片描述

查看统计信息

ip -s link

输出样例


1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    RX: bytes  packets  errors  dropped overrun mcast
    1548       18       0       0       0       0
    TX: bytes  packets  errors  dropped carrier collsns
    1548       18       0       0       0       0
2: eno16777736: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000
    link/ether 00:0c:29:af:e9:5d brd ff:ff:ff:ff:ff:ff
    RX: bytes  packets  errors  dropped overrun mcast
    167463237  118159   0       0       0       0
    TX: bytes  packets  errors  dropped carrier collsns
    3242007    52646    0       0       0       0

这里写图片描述

===============================================
2.其次,使用如下的两个命令来查看哪里可以找得到ifconfig
请输入如下命令:

yum provides ifconfig

输出结果:


[root@localhost network-scripts]# yum provides ifconfig
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.sohu.com
net-tools-2.0-0.22.20131004git.el7.x86_64 : Basic networking tools
源    :@base
匹配来源:
文件名    :/usr/sbin/ifconfig

这里写图片描述

或者使用如下命令:

yum whatprovides ifconfig

输出结果


[root@localhost network-scripts]# yum whatprovides ifconfig
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.sohu.com
net-tools-2.0-0.22.20131004git.el7.x86_64 : Basic networking tools
源    :@base
匹配来源:
文件名    :/usr/sbin/ifconfig

这里要特别注意!“provides”或者“whatprovides”开关用于找出某个包提供了某些功能或文件。

就像你在上面的输出中所看到的,net-tools包提供了ifconfig命令。因此,让我们安装net-tools包来使用ifconfig命令。

yum install net-tools

安装成功后,使用ifconfig -a

ifconfig -a

结果如下


[root@localhost network-scripts]# ifconfig  -a
eno16777736: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.79.128  netmask 255.255.255.0  broadcast 192.168.79.255
        inet6 fe80::20c:29ff:feaf:e95d  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:af:e9:5d  txqueuelen 1000  (Ethernet)
        RX packets 118379  bytes 167485055 (159.7 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 52837  bytes 3275741 (3.1 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 0  (Local Loopback)
        RX packets 18  bytes 1548 (1.5 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 18  bytes 1548 (1.5 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

搞定!

参考博客
CentOS7如何设置网络自动启动

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值