centos8 centos7 修改网卡名称 恢复传统的网卡命名 并指定eth0网卡取出IP地址(增加sed方法)

[root@centos8 ~]#: vim /etc/default/grub
GRUB_CMDLINE_LINUX="resume=UUID=7c877369-a4e8-4dc6-bcaf-b65cd5cd567b rhgb quiet net.ifnames=0"  
[root@centos8 ~]#: grub2-mkconfig -o /boot/grub2/grub.cfg
[root@centos8 ~]#:reboot
以上方法centos8 centos7均可通用

sed -r 's/(GRUB_CMDLINE_LINUX.*)"$/\1 net.ifnames=0"/' /etc/default/grub
可用sed看效果,需要修改需要加 -i.bak 将原文件备份

ifconfig eth0| head -2 | tail -1 |tr -s ' '|cut -d' ' -f 3
以上方法centos6-8 均可通用

ifconfig eth0 | sed -n '2p'|sed -r 's@.*inet (.*)  net.*@\1@'
ifconfig eth0 | sed -n '2p'|sed -r 's@.*(inet )(.*)(  net.*)@\2@'
ifconfig eth0 | sed -r '2!d;s@.*(inet )(.*)(  net.*)@\2@'
以上三种sed效果
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值