在 Linux 中 ifconfig 无法启动/找不到命令,常见原因有以下几种(按出现频率排序):
现代 Linux 发行版(如 Ubuntu 18.04+、CentOS 8+)默认不再安装 net-tools。
现象
$ ifconfig
-bash: ifconfig: command not found
解决
# Debian / Ubuntu
sudo apt update
sudo apt install net-tools
# CentOS / RHEL
sudo yum install net-tools
# 或
sudo dnf install net-tools
ifconfig 已被官方弃用,推荐使用 ip 命令:
ip addr # 查看网卡
ip link # 查看链路状态
ip route # 查看路由
启用网卡:
sudo ip link set eth0 up
即使 ifconfig 能用,也可能看不到网卡:
ifconfig -a
若网卡是 DOWN 状态:
sudo ifconfig eth0 up
某些系统由网络管理服务控制:
# 查看状态
systemctl status NetworkManager
# 重启网络
sudo systemctl restart NetworkManager
ip 命令如果你能贴出具体报错信息(命令 + 输出),我可以更精确地判断原因。