在 Debian 中,ifconfig 默认可能不可用,因为它属于 net-tools 工具包,而现代 Debian 倾向使用 ip 命令(来自 iproute2)。
如果你仍然想使用 ifconfig,可以按以下步骤启用:
sudo apt update
sudo apt install net-tools
安装完成后即可直接使用:
ifconfig
which ifconfig
应显示类似:
/sbin/ifconfig
如果没有权限,可用:
/sbin/ifconfig
如果你执行 ifconfig 仍提示 command not found,可能是 PATH 问题:
export PATH=$PATH:/sbin
永久生效(写入 ~/.bashrc 或 /etc/profile):
echo 'export PATH=$PATH:/sbin' >> ~/.bashrc
source ~/.bashrc
Debian 官方更推荐使用 ip 命令:
ip addr
ip link
ip route
| 旧命令 | 新命令 |
|---|---|
| ifconfig | ip addr / ip link |
| route | ip route |
| netstat | ss |
✅ 最快启用方式:
sudo apt install net-tools
如果你愿意,我也可以帮你:
ifconfig 与 ip 的用法