LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   cp command change the file permission? (https://www.linuxquestions.org/questions/linux-general-1/cp-command-change-the-file-permission-96207/)

myunicom 09-24-2003 03:28 AM

cp command change the file permission?
 
I use cp command to backup large file, I find that cp command change the file ower, I want to know whether cp command change the file permission or not.thanks!

aizkorri 09-24-2003 03:46 AM

it depends on who is copying the files. e .g
If I am userOne and I copy some file from userTwo I became the owner of that copy.

whansard 09-24-2003 03:53 AM

cp --preserve

when you use cp, you are "creating" a file, so the user
creating it owns it. you can have a default umask that
will set permissions of a file when you create it.

myunicom 09-24-2003 04:06 AM

Thank you very much!

I(root user) copy a directory(dirA) including many files that have different permission and owner to another directory(dirB).I find that the files owner in dirB are changed to ROOT, I want to know if all the dirB files owner are chaged to ROOT, and the files permission in dirB are changed. I want to copy the dirB files back to the dirA in the future, if the copy change the files owner and permission , it will be a trouble. thanks!

DirA------------------------->DirB (permission,fileowner changed ?)

shawnchin 09-24-2003 04:10 AM

when using cp to backup files, it is adviceable to use cp -a, a being an option for archive, which will preserve links, permissions, ownerships, and recursively...


Cheers

myunicom 09-24-2003 04:18 AM

Thank you !

From myunicom

whansard 09-24-2003 08:15 AM

for backing up
tar clfvzp - directory > /archivename.tar.gz
when extracting
tar zxvfp /archivename.tar.gz --same-owner


All times are GMT -5. The time now is 09:17 AM.