在 Debian 里 ifconfig 报错,常见原因和解决办法如下:
新版本 Debian 默认不再安装 ifconfig,它是 net-tools 包里的。
bash: ifconfig: command not found
sudo apt update
sudo apt install net-tools
装完后再用:
ifconfig
Debian 现在推荐使用 ip 命令(iproute2,默认已装):
ip addr # 看 IP
ip link # 看网卡
ip route # 看路由
功能比 ifconfig 更全,也更适合新系统。
which ifconfig
如果是 /sbin/ifconfig,但普通用户用不了:
sudo ifconfig
或
su -
有些 Docker / LXC 环境连 net-tools 都没有,也不建议装,直接用:
ip addr
✅ 最快解决办法:
sudo apt install net-tools
✅ 更推荐:
ip addr
如果你方便的话,可以把具体报错内容贴出来,我可以更精准帮你判断。