1

This question already has an answer here:

How do I copy all the folder, subfolders and files permissions (recursively) from /www_03062018 to my new /www ?

I came across this post: Clone permissions for all files in a folder

chmod --reference=RFile file

Which didn't help much, it did apply a change for the main folder /www but didn't apply on its subfolders and files.

i have tried:

chmod -R --reference=/www_03062018 /www

and it didn't work.

My situation:

I have 2 folders on my Ubuntu machine: /www and /www_03062018.

/www is a "git clone" from the production machine.

/www_03062018 is my old directory that i used to work on and upload files via FTP.

I started to use GIT and when I clone a directory - all its folder ownerships and file accesses settings doesn't get cloned too.

marked as duplicate by music2myear, G-Man, Pimp Juice IT, DrZoo, mpy Jun 19 '18 at 18:37

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1
cd /www
find . -path ./.git -prune -or -exec chmod --reference '/www_03062018/{}' '{}' \; -exec chown --reference '/www_03062018/{}' '{}' \;

retrieved and adapted from here

  • tested it on 2 folders: test1 and test2. each have the same files 111/222/333.txt with different permissions. test1 has the default ones. test2 has 777 permissions. this is the error i get. – Rick Sanchez Jun 3 '18 at 12:20
  • find /home/myubuntuuser/Desktop/test1 -exec chmod --reference /home/myubuntuuser/Desktop/test2/{} {} \; – Rick Sanchez Jun 3 '18 at 12:20
  • chmod: failed to get attributes of '/home/myubuntuuser/Desktop/test2//home/myubuntuuser/Desktop/test1': No such file or directory chmod: failed to get attributes of '/home/myubuntuuser/Desktop/test2//home/myubuntuuser/Desktop/test1/111.txt': No such file or directory chmod: failed to get attributes of '/home/myubuntuuser/Desktop/test2//home/myubuntuuser/Desktop/test1/222.txt': No such file or directory chmod: failed to get attributes of '/home/myubuntuuser/Desktop/test2//home/myubuntuuser/Desktop/test1/333.txt': No such file or directory – Rick Sanchez Jun 3 '18 at 12:21
  • right, I made a mistake. I needed relative paths. – yarl Jun 3 '18 at 12:30
  • (I edited my post) – yarl Jun 3 '18 at 12:36

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