在Linux系统中,ipconfig 是Windows下的命令,而Linux使用的是 ifconfig 或更现代的 ip 命令。以下是解决方案和替代方法:
ip 命令(推荐)bash
ip addr show # 查看所有网络接口信息(IP、MAC等)
ip route show # 查看路由表
ip link show # 查看链路状态
优势:ip 是 net-tools(含ifconfig)的现代替代工具,功能更强大,且默认集成在大多数Linux发行版中。
net-tools(获取ifconfig)如果习惯使用ifconfig,需手动安装net-tools包:
bash
sudo apt install net-tools # Debian/Ubuntu
sudo yum install net-tools # CentOS/RHEL
sudo dnf install net-tools # Fedora
安装后即可使用:
bash
ifconfig
nmcli(NetworkManager命令行工具):
bash
nmcli device show # 查看详细网络配置hostname -I:快速获取本机IP地址。ss 或 netstat:查看网络连接和端口状态。bash
systemctl status NetworkManager # 检查NetworkManager服务
systemctl status networking # (部分系统)检查基础网络服务
ip或ifconfig),可能是:
PATH环境变量异常,尝试绝对路径:/sbin/ip 或 /usr/sbin/ifconfig。ip 命令,功能全面且无需额外安装。ifconfig可安装net-tools,但未来可能逐步淘汰。如有其他具体需求(如无线网络、DNS配置等),可进一步提供信息!