Thursday, December 29, 2016

Copy folder in linux without changing the existing permission.

 Sometimes we need to copy some folders without changing its permissions. But when we copy a folder to a new location, the new copy will have the copying person's permission. (Ex: If the copying person is 'root' then the new folder will have the permission only for root.
 One can copy the folder and then change the permission back to the original user. But this will difficult it the folder contains different permissions for different files or folders.
 So the solution for this is use "-pdR" options while copying.

> cp -pdR <file folder_name> <new_location>

No comments: