LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-05-2006, 07:27 PM   #1
stefaandk
Member
 
Registered: Jun 2005
Distribution: Centos
Posts: 215

Rep: Reputation: 30
Question Copy files retaining ownership/permissions


How can I do this, I hear about cpio but I can't get that to do it either.
 
Old 09-05-2006, 07:57 PM   #2
nilleso
Member
 
Registered: Nov 2004
Location: ON, CANADA
Distribution: ubuntu, RHAS, and other unmentionables
Posts: 372

Rep: Reputation: 31
cp -p and/or scp -p will probably work for you

...from cp man page
-p Preserve. cp duplicates not only the contents of
source_file, but also preserves the owner and group
id, permission modes, modification and access time,
ACLs, and extended attributes, if applicable. Notice
that the command may fail if ACLs are copied to a file
system without appropriate support. The command will
not fail if unable to preserve extended attributes,
modification and access time, or permission modes. If
unable to preserve owner and group id, cp will not
fail, and it will clear S_ISUID and S_ISGID bits in
the target. cp will print a diagnostic message to
stderr and return a non-zero exit status if unable to
clear these bits.

In order to preserve the owner and group id, permis-
sion modes, and modification and access times, users
must have the appropriate file access permissions.
This includes being superuser or the same owner id as
the destination file.

cheers
 
Old 09-05-2006, 08:13 PM   #3
stefaandk
Member
 
Registered: Jun 2005
Distribution: Centos
Posts: 215

Original Poster
Rep: Reputation: 30
Thanks, that does the trick!
 
Old 09-05-2006, 08:29 PM   #4
stefaandk
Member
 
Registered: Jun 2005
Distribution: Centos
Posts: 215

Original Poster
Rep: Reputation: 30
Brings me to another question though, I already have a full structure of files and I now want to copy permissions and file ownerships only from a similar structure, can that be done?
 
Old 09-07-2006, 09:25 PM   #5
nilleso
Member
 
Registered: Nov 2004
Location: ON, CANADA
Distribution: ubuntu, RHAS, and other unmentionables
Posts: 372

Rep: Reputation: 31
I've never come across anyone doing that. I suppose it is possible to script it. It would likely take more time that it would to (re)copy the files
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Group Permissions and Ownership of files and folders bugeyemonster Linux - General 1 04-19-2006 02:52 AM
Apache can't write files despite permissions/ownership linuxChique Linux - Software 2 02-20-2006 11:08 AM
changing permissions and ownership on many files and folders Cinematography Linux - General 4 08-01-2005 04:20 AM
Question about ownership/permissions infornography Linux - Newbie 7 07-28-2004 06:57 AM
write permissions / ownership bynaar Slackware 15 08-08-2002 05:25 AM


All times are GMT -5. The time now is 10:42 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration