i have a tree of files with correct permission. then i have a (filewise) identical tree (with different file contents tough) with wrong permissions.
how can i transfer the permissions layout from one tree to another?
|
i have a tree of files with correct permission. then i have a (filewise) identical tree (with different file contents tough) with wrong permissions. how can i transfer the permissions layout from one tree to another? |
|||
|
|
|
It can be done with the following shell line:
simply set the right value for D1 and D2 variables, point them to the source and destination directories, run and the dirs will have permissions in sync. |
|||||||||||||
|
|
If you have the source and dest, you can synchronize your permissions with
It will not transfer the data, just permissions... |
|||||||||
|
|
One thing you could do is use the find command to build a script with the commands you need to copy the permissions. Here is a quick example, you could do a lot more with the various printf options, including get the owner, group id, and so on.
|
|||||||||
|
|
I just learned a new and simple way to accomplish this:
This will generate a list with all permissions and ownerships. Then go to one level above the destination and restore the permissions with
The reason you have to be one level above is that all paths in perms.acl are relative. Should be done as root. |
|||
|
|
|
Two ways:
(in the latter case /dst must exist) Edit: sorry, I misread. Not what you asked. |
|||
|
|
I think I'd write a perl script to do it. Something like:
Then do something like this:
I wrote this off the top of my head, and it has not been tested; so check it before you let it run rampant. This only fixes permissions on directories that exist; it won't change permissions on files, nor will it create missing directories. |
|||
|
|