
我有一個 30GB 的網站,其中包含大量資料夾和檔案。我希望所有資料夾都具有 745 權限,所有檔案都具有 644 權限chmod -R 745 public_html/
。如何使用 chmod 將所有資料夾(僅)更改為此權限?
答案1
除非您故意不希望群組成員存取該目錄(這將是一種不尋常的情況),否則您應該使用755
目錄。
您可以使用find
。
對於文件:
find /path/to/public_html/ -type f -exec chmod 0644 {} +
對於目錄(使用 755):
find /path/to/public_html/ -type d -exec chmod 0755 {} +
-type f
只會找到文件並chmod 0644
相應執行-type d
將僅查找目錄並chmod 0755
對其執行。