2

I have a question. So I have 2 folders, both of which have the same files in them, but some with different content, but the same names. What I want to do is clone all of the file permissions from one folder, into the permissions for another folder. Is this possible?

0

2 Answers 2

0

This is a duplicate of Unix: Is there a way to "copy" file or directory permissions? .

You can achieve this by typing this:

chmod --reference=RFile file
9
  • Could I use -R to do it to all files in the dir? Jul 29, 2013 at 23:03
  • I am on my phone, can't try right now, but you should probably be able to. Otherwise, you could make a script that would recurse into subdirectories and do this for all the files. Jul 29, 2013 at 23:06
  • 2
    It didnt seem to do it to recursively... I ran chmod -R --reference=/home/tcagame_svc4/karl/4/garrysmod/ /home/tcagame_svc7/stefen/7/garrysmod/ Jul 29, 2013 at 23:09
  • Good idea by Tiago CA, maybe you should provide an asterisk after the slash, without specifying -R. Jul 29, 2013 at 23:40
  • 1
    Tiago CA's answer doesn't work for me, but this does: for i in foo/*; do j=$(basename $i); chmod bar/$j --reference foo/$j; done (you want to copy the permissions from foo to bar and they are flat directories). Jul 30, 2013 at 0:12
-1

This seems work for me:

$ sudo chmod --reference foo/ baz/*
1
  • 3
    On my system (coreutils 8.13) that copies the permissions from the foo directory to each file in bar. Jul 30, 2013 at 0:15

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