智传网优云课堂,专注分享IT技术
与IT技术爱好者一起共同学习进步

ubuntu ifconfig 命令找不到的解决方法

1. 前言

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

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<UP,BROADCAST,RUNNING,MULTICAST> 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<UP,LOOPBACK,RUNNING> 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

赞(2)
未经允许不得转载:Linux入门学习到精通 » ubuntu ifconfig 命令找不到的解决方法
分享到: 更多 (0)

学习QQ群:557371664

关注微信公众号自助视频学习

评论 抢沙发

评论前必须登录!