21

Suppose I have a directory on Linux with a bunch of files and subdirectories. This is that root directory:

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.

modulitos
  • 14,737
  • 16
  • 67
  • 110
Dave L.
  • 9,595
  • 7
  • 43
  • 69
  • @Lucas -- No I didn't want to alter the ownership; just the permissions that were granted. See the responses if you still don't get it. – Dave L. Oct 20 '14 at 20:39

2 Answers2

49

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.

Dennis Williamson
  • 346,391
  • 90
  • 374
  • 439
4

That's simple:

chmod g=u <file>
lazyfrosch
  • 151
  • 4