Suppose I have a directory on Linux with a bunch of files and subdirectories. This is that root directory:
假設我在Linux上有一個目錄,包含一堆文件和子目錄。這是根目錄:
drwxr-xr-x 13 user1 group1 4096 May 7 15:58 apps
Now, I only want to alter the group portion of those permissions. I want to alter it in such a way that it exactly matches the owner portion. The result for that directory would be:
現在,我只想更改這些權限的組部分。我想以一種與所有者部分完全匹配的方式改變它。該目錄的結果將是:
drwxrwxr-x 13 user1 group1 4096 May 7 15:58 apps
But, I want a script or command to do this automatically, not just for that directory but for every subdirectory and file recursively under it. Anyone know how?
但是,我想要一個腳本或命令自動執行此操作,不僅針對該目錄,而且針對每個子目錄和文件遞歸地執行此操作。誰知道怎么樣?
Thanks.
謝謝。
2 个解决方案
#1
40
Give this a try (test it first):
嘗試一下(首先測試):
chmod -R g=u apps
The = copies the permissions when you specify a field (u, g or o) on the right side or sets it absolutely when you specify a permission (r, w or x) on the right.
=當您在右側指定字段(u,g或o)時復制權限,或者在右側指定權限(r,w或x)時將其設置為絕對。
#2
3
That's simple:
這很簡單:
chmod g=u