Fedora 極簡安裝預設不包含 net-tools (含 ifconfig、netstat、route、arp),且 /sbin、/usr/sbin 不在 root PATH 中。解決:安裝 net-tools、修正 /etc/profile 將 sbin 目錄加入 PATH。

ifconfig
bash: ifconfig: command not found
netstat
bash: netstat: command not found
# 搜尋提供 ifconfig 的套件
dnf provides ifconfig
# 或
yum provides ifconfig
# 結果: net-tools
# 安裝
dnf install -y net-tools
# 或
yum install -y net-tools
# 臨時生效
export PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin
# 永久生效:編輯 /etc/profile
vi /etc/profile
# 找到 Path manipulation 區塊,註解掉 if 判斷,直接保留 pathmunge
# Path manipulation
# if [ "$EUID" = "0" ]; then
pathmunge /sbin
pathmunge /usr/sbin
pathmunge /usr/local/sbin
# fi
# 重新登入或 source /etc/profile 生效
| 傳統指令 (net-tools) | 現代指令 (iproute2) |
|---|---|
ifconfig | ip addr show / ip a |
netstat -tuln | ss -tuln |
route -n | ip route show |
arp -n | ip neigh show |