新装Ubuntu系统没有ifconfig命令?一键恢复这经典命令

1. 前言

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

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.

安装apt-file

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.

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

使用apt-file更新本地缓存

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

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

查询结果:

net-tools: /sbin/ifconfig

如下图

查找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

测试ifconfig命令

7. 总结

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

使用ip addr替代ifconfig

https://www.linuxrumen.com/rmxx/952.html

点击了解更多,快速查看更多的技术文章列表。

声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2019年7月4日
下一篇 2019年7月4日

相关推荐