centos7 ifconfig命令找不到_新装Ubuntu系统没有ifconfig命令?一键恢复这经典命令

请关注本头条号,每天坚持更新原创干货技术文章。

如需学习视频,请在微信搜索公众号“智传网优”直接开始自助视频学习

1. 前言

ubuntu ifconfig 命令找不到,是因为没有安装对应的软件包 。教大家一个方法,即查询某个命令由哪个软件包提供。

da03e09079724ab58f41eb712f2e37c8

Ubuntu系统

2. 安装apt-file:

zcwyou@ubuntu1804:~$ sudo apt install -y apt-file

安装过程如下,即表示安装成功。

Setting up libapt-pkg-perl (0.1.33build1) …

Setting up libexporter-tiny-perl (1.000000-2) …

Processing triggers for man-db (2.8.3-2ubuntu0.1) …

Setting up libregexp-assemble-perl (0.36-1) …

Setting up liblist-moreutils-perl (0.416-1build3) …

Setting up apt-file (3.1.5) …

The system-wide cache is empty. You may want to run 'apt-file update'

as root to update the cache.

a883c6202d5e46d297420542cab7b625

安装apt-file

a06c7ea26bc6444c99b6114bcfd84787

3. 更新本地缓存

zcwyou@ubuntu1804:~$ sudo apt-file update

需要联网拉取数据,部分输出如下:

Fetched 73.4 MB in 37s (2,002 kB/s)

Reading package lists… Done

Building dependency tree

Reading state information… Done

All packages are up to date.

看到下图证明缓存更新完毕。

fdee76c6c0164b0c8652a3db8b919b9d

使用apt-file更新本地缓存

4. 查找ifconfig命令对应的软件包

zcwyou@ubuntu1804:~$ sudo apt-file search bin/ifconfig

查询结果:

net-tools: /sbin/ifconfig

如下图

94d4473cd1e74186942ae877d3e6a90c

查找ifconfig命令对应的软件包

可以看到,ifconfig对应的软件包为net-tools

5. 安装net-tools套件

zcwyou@ubuntu1804:~$ sudo apt install net-tools

按提示输入密码

[sudo] password for zcwyou:

6. 测试ifconfig命令

zcwyou@ubuntu1804:~$ sudo ifconfig

我的服务器输出信息如下:

ens33: flags=4163 mtu 1500

inet 172.16.87.140 netmask 255.255.255.0 broadcast 172.16.87.255

inet6 fe80::20c:29ff:fef1:b5e1 prefixlen 64 scopeid 0x20

ether 00:0c:29:f1:b5:e1 txqueuelen 1000 (Ethernet)

RX packets 5411 bytes 1269368 (1.2 MB)

RX errors 0 dropped 0 overruns 0 frame 0

TX packets 1808 bytes 266933 (266.9 KB)

TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

lo: flags=73 mtu 65536

inet 127.0.0.1 netmask 255.0.0.0

inet6 ::1 prefixlen 128 scopeid 0x10

loop txqueuelen 1000 (Local Loopback)

RX packets 222 bytes 19922 (19.9 KB)

RX errors 0 dropped 0 overruns 0 frame 0

TX packets 222 bytes 19922 (19.9 KB)

TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

f53243abb63248afae3fc18d1f158fa2

测试ifconfig命令

7. 总结

已经成功安装并使用ifconfig。其实,ifconfig并不是必要安装的,使用Linux命令ip addr也具有同样的效果,如下图。

0e1e4497963d4051afc984707a23b322

使用ip addr替代ifconfig

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值