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

Linux 一般使用者 Ping 出現 Operation not permitted 解決辦法

編輯:Linux 教學

錯誤訊息

ping: icmp open socket: Operation not permitted

原因分析

  • ping 需建立 ICMP 原始 Socket (RAW Socket),僅 Root 擁有權限。
  • 正常情況下 /bin/ping 應具備 SUID 屬性 (-rwsr-xr-x),讓一般用戶以 Root 權限執行。
  • 若權限被誤改 (如 chmod 755),SUID 遺失,導致一般用戶無法執行。

解決:恢復 SUID 位元

chmod u+s /bin/ping
# 或
chmod 4755 /bin/ping

驗證

ls -l /bin/ping
# 應顯示 -rwsr-xr-x  (注意 s 取代 x 於擁有者執行位)
ping www.google.com   # 一般用戶應可正常運作

補充

  • 同理適用於 traceroute、arping 等需 RAW Socket 的工具。
  • 若系統採用 capabilities 機制 (setcap cap_net_raw+ep /bin/ping),亦可不依賴 SUID,但傳統做法仍以 SUID 為主。
Copyright © Windows教程網 All Rights Reserved