在 Debian 里 ifconfig 命令找不到或不可用,通常不是“坏掉了”,而是因为:
ip 命令 / systemd-networkd / NetworkManager下面按常见情况给你修复方法。
bash: ifconfig: command not found
sudo apt update
sudo apt install net-tools
安装完成后:
ifconfig
可能是:
ip 管理但 ifconfig 不显示ip addr
sudo ip link set eth0 up
或 Debian 传统方式:
sudo ifup eth0
sudo dhclient eth0
或
sudo ifconfig eth0 up
sudo dhclient eth0
其实官方更推荐:
ip a
ip route
例如:
ip addr show
如果你习惯 /etc/network/interfaces:
编辑:
sudo nano /etc/network/interfaces
示例:
auto eth0
iface eth0 inet dhcp
然后:
sudo systemctl restart networking
| 场景 | 建议 |
|---|---|
| 临时查看 IP | ✅ ifconfig |
| 服务器长期配置 | ❌ 不推荐 |
| 新系统 | ✅ 用 ip |
如果你愿意,可以告诉我:
cat /etc/debian_version)我可以给你精确修复命令。