centOS7下ifconfig提示command not found

在电脑中安装linux后,输入ifconfig想要查看IP地址,却提示command not found 。以下为解决办法。

1.1 查看是否真的没有设置IP地址:

命令行中输入ip addr,若看到有ip地址,则说明已设置正常,若没有则需要设置一个

ip addr

1.2 确认sbin目录是否存在:

在命令行中输入:

cd /sbin

1.3 确认是否安装ifconfig命令:

在sbin目录中输入ls | grep 'ifconfig',没有则说明没有安装。

ls | grep 'ifconfig'

1.4 因为我已经安装了,没有则继续。

1.5 安装net-tools,因为该包中包含ifconfig命令:

sudo yum install net-tools

1.6 安装过程中询问是否安装,输入’y’并回车即可。因为我已经安装了,所以此处无需做任何处理。

1.7 再次在命令行中输入ifconfig,查看到ip则安装成功。

 

原文地址:https://www.cnblogs.com/liyhbk/p/13665848.html