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

root 也刪不掉的檔案?Linux 不可變屬性 (chattr) 解除教學

編輯:關於 Linux

root 擁有最高權限,卻偶爾無法刪除普通檔案,提示 Operation not permitted。罪魁禍首通常是檔案被設定 不可變屬性 (immutable attribute)。本文示範如何檢查與移除。

問題重現

  1. 一般用戶刪除失敗(權限不足)。
  2. 切換 root 後仍失敗,提示相同錯誤。

解決步驟

  1. 查看檔案屬性
    使用 lsattr 檔案名,若輸出含 i 字樣,表示設定了不可變屬性。
  2. 移除屬性
    以 root 執行 chattr -i 檔案名 取消不可變屬性。
  3. 再次嘗試刪除
    此時一般用戶即可正常刪除。

chattr +i 可保護關鍵系統檔案防誤刪,chattr -i 則解除保護。善用此機制兼顧安全與靈活。

Copyright © Windows教程網 All Rights Reserved