如何解决Ubuntu提示没有找到ifconfig命令

刘遄 -
如何解决Ubuntu提示没有找到ifconfig命令

在我们新安装的Ubuntu 20.04操作系统中,我们想要查看ip地址,发现使用ifconfig命令,提示找不到这个命令。在下面文章汇总,会介绍如何安装这个工具。
当在运行ifconfig命令是,提示下面的错误,就代表没有安装它:

bob@ubuntu-20-04:~$ ifconfig

Command 'ifconfig' not found, but can be installed with:

sudo apt install net-tools
或者提示下面的信息:

-bash: ifconfig: command not found
在Ubuntu 20.04中,不建议使用ifconfig命令。这就是为什么会收到有关缺少的ifconfig命令的错误的原因。若想要查看ip地址。可以使用ip addr命令,它几乎可以执行与ifconfig命令相同的任务,如下面的代码所示:

bob@ubuntu-20-04:~$ ip addr
1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000

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: ens33: mtu 1500 qdisc fq_codel state UP group default qlen 1000

link/ether 00:0c:29:40:d4:6f brd ff:ff:ff:ff:ff:ff
inet 192.168.43.174/24 brd 192.168.43.255 scope global dynamic noprefixroute ens33
   valid_lft 1337sec preferred_lft 1337sec
inet6 fe80::7559:c488:6787:289d/64 scope link noprefixroute 
   valid_lft forever preferred_lft forever

如何解决Ubuntu提示没有找到ifconfig命令如何解决Ubuntu提示没有找到ifconfig命令
从上面代码输出中可以看到,该命令仍将显示所有网络接口的IP地址和其他统计信息。

如果习惯使用旧的ifconfig命令,则需要安装net-tools软件包。net-tools是一个工具包,其中包含构成Linux网络基础的一系列程序。这些包括:

ifconfig
netstat
dig
hostname
route
arp
iptunnel
解决ifconfig命令找不到的问题
要解决以上错误,就需要安装net-tools工具包:

bob@ubuntu-20-04:~$ sudo apt install net-tools
如何解决Ubuntu提示没有找到ifconfig命令如何解决Ubuntu提示没有找到ifconfig命令
安装成功完成后,再次尝试运行ifconfig命令,可以看到熟悉的面孔了。

总结
ifconfig已经逐渐被ip addr取代了,因为现在大部分发行版本,比如Centos\RHEL、Fedora、Ubuntu等系统都取消了net-tools工具包了。

特别申明:本文内容来源网络,版权归原作者所有,如有侵权请立即与我们联系(cy198701067573@163.com),我们将及时处理。

Nginx介绍

Nginx (engine x) 是一个高性能的HTTP和反向代理web服务器,同时也提供了IMAP/POP3/SMTP服务。

Tags 标签

Nginxlinux运维centosubuntu

扩展阅读

加个好友,技术交流

1628738909466805.jpg