在 Debian 中,ifconfig 命令属于 net-tools 软件包,而较新的 Debian 版本(如 Debian 9 及以后)默认 不再安装 net-tools,所以会出现“command not found”。
sudo apt update
sudo apt install net-tools
安装完成后即可使用:
ifconfig
which ifconfig
或
ls -l /sbin/ifconfig
通常位于:
/sbin/ifconfig
注意:
/sbin可能不在普通用户的PATH中,可用:
/sbin/ifconfig
或使用 sudo
Debian 推荐使用 ip 命令(来自 iproute2):
ip addr # 查看网卡和 IP
ip link # 查看网卡状态
ip route # 查看路由
| 命令 | 状态 |
|---|---|
| ifconfig | 需安装 net-tools |
| ip | 系统自带,推荐 |
如果你是在 Docker / 容器 / 最小化 Debian 环境,也可以告诉我,我可以给你对应的解决办法。