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

chown 變更檔案擁有者與群組:語法、遞迴、參考檔、僅變更符合條件、管理員權限、實戰範例

編輯:關於 Linux

chown 變更檔案擁有者/群組,需 root 權限,一般用戶不可變更他人檔案擁有者。

語法格式

chown [選項]... [擁有者][:[群組]] 檔案...

關鍵參數

  • -R:遞迴處理目錄樹。
  • -v:顯示變更詳情。
  • -c:僅顯示實際變更者。
  • --reference=檔案:參考檔案擁有者/群組。
  • --from=目前擁有者:群組:僅當符合時變更(防誤改)。
  • -h / --dereference:作用於符號連結本身而非目標。

範例

  • 變更擁有者與群組:chown mail:mail log2012.log
  • 遞迴變更目錄:chown -R www:www /var/www/html
  • 參考檔案:chown --reference=file1 file2
  • 僅變更群組:chown :group file(等同 chgrp)。

配合 find 批次變更:find /path -user olduser -exec chown newuser:newgroup {} \;。

上一頁123下一頁共3頁

Copyright © Windows教程網 All Rights Reserved