Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> Linux 系統教學 >> 關於 Linux

Fedora 找不到 ifconfig/netstat 指令解決:net-tools 套件安裝與 PATH 環境變數修正

編輯:關於 Linux

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

Fedora 指令找不到示意圖

問題現象

ifconfig
bash: ifconfig: command not found
netstat
bash: netstat: command not found

解決方案一:安裝 net-tools (根本解決)

# 搜尋提供 ifconfig 的套件
dnf provides ifconfig
# 或
yum provides ifconfig
# 結果: net-tools

# 安裝
dnf install -y net-tools
# 或
yum install -y net-tools

解決方案二:修正 PATH 環境變數 (輔助)

# 臨時生效
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 生效

現代替代指令 (iproute2 套件,預設已安裝)

建議

  • 新腳本優先使用 ip/ss,功能更強、輸出可機器解析
  • 相容舊腳本時安裝 net-tools
  • 修正 PATH 確保 /sbin、/usr/sbin 可用
Copyright © Windows教程網 All Rights Reserved
傳統指令 (net-tools)現代指令 (iproute2)
ifconfigip addr show / ip a
netstat -tulnss -tuln
route -nip route show
arp -nip neigh show