I have a folder with some files, which each have different permissions. Some are read-only, some are read/write, some are read/execute.

How can I copy the permissions from user to group, so that for example a file marked read-write for user will be set to read-write for group, but a file read-executable for a user will be set read-executable for the group.

Can this be done with a single command?


chmod from coreutils understands such assignments:

chmod g=u file
  • just a joke :) #! /bin/bash for FILE in * do chmod g=$(ls -l $FILE | cut -c 2,3,4) $FILE done – Hojat Taheri Apr 4 '13 at 14:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.