48

I want to set the group permissions for all files and subdirectories within a certain parent directory to whatever the user permission setting for that specific file or directory is.

For example, everything under /path/to/parentdir

# Permissions before
# Path                      Permissions
/path/to/parentdir/file1    755
/path/to/parentdir/file2    644
/path/to/parentdir/file3    600

# Permissions after
/path/to/parentdir/file1    775
/path/to/parentdir/file2    664
/path/to/parentdir/file3    660

I'm hoping there's a simple way to do this in hopefully one command. I can think of ways using a script with a bunch of commands, but it feels like there should be a pretty direct way of doing it.

Thanks in advance!

1 Answer 1

78

This is what you want:

chmod -R g=u directory
1
  • 3
    So simple. Delightful.
    – sehe
    Commented Mar 23, 2021 at 0:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .