user816328
user816328

Reputation:

How to copy directory permissions

I'm curious how to copy the permission from directory to another. Any idea?

Thanks

Upvotes: 1

Views: 2265

Answers (3)

Vasilis Lourdas
Vasilis Lourdas

Reputation: 1179

Try cp -a from_dir to_dir. It will maintain the permissions from the first directory.

Upvotes: 1

Rod
Rod

Reputation: 55752

Since you mentionned python, I assume you are looking for

shutil.copymode(src, dst)

See the documentation on shutil

Upvotes: 2

Manoj Govindan
Manoj Govindan

Reputation: 74705

shutil.copymode should help you out. From the documentation:

shutil.copymode(src, dst)

Copy the permission bits from src to dst. The file contents, owner, and group are unaffected. src and dst are path names given as strings.

I tested this in Ubuntu Jaunty using Python 2.6.2 and it worked for me.

Upvotes: 5

Related Questions