1

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

I came across this question on Super User.

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 its folder ownerships and file accesses settings don't get cloned along with it.

Zanna
  • 72,312
Kar19
  • 459
  • 1
  • 7
  • 28

1 Answers1

2

cd to the new directory which you want to give new permissions - in my case:

cd /www

For CHMOD this worked:

find . -path ./.git -prune -or -exec chmod --reference '/www_03062018/{}' '{}' ';' 

And for CHOWN this worked:

find . -path ./.git -prune -or -exec chown --reference '/www_03062018/{}' '{}' ';'

Hope this helps others :) !

Kar19
  • 459
  • 1
  • 7
  • 28