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 修改文件擁有者與群組:chown 命令用法

編輯:Linux 教學

基本語法

chown [用戶]:[群組] 文件路徑

實戰範例

# 將 /home/dasusr1/.profile 擁有者改為 dasusr1,群組改為 dasadm
chown dasusr1:dasadm /home/dasusr1/.profile

# 遞歸修改目錄樹
chown -R user:group /path/to/dir

執行前後對比

# 修改前
-rw-r--r-- 1 root root 675 Jan 6 00:09 /home/dasusr1/.profile

# 修改後
-rw-r--r-- 1 dasusr1 dasadm 675 Jan 6 00:09 /home/dasusr1/.profile

常用變體

  • chown user file:僅修改擁有者
  • chown :group file:僅修改群組(等同 chgrp)
  • chown -R user:group dir:遞歸處理目錄及子項
  • chown --reference=ref_file target_file:參考文件屬性

權限要求

需具備 root 權限或文件擁有者且目標群組為當前用戶所屬群組之一。

Copyright © Windows教程網 All Rights Reserved