LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 09-24-2003, 03:28 AM   #1
myunicom
LQ Newbie
 
Registered: Sep 2003
Posts: 14

Rep: Reputation: 0
Question 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!
 
Old 09-24-2003, 03:46 AM   #2
aizkorri
Member
 
Registered: Feb 2002
Location: Basque Country
Distribution: Fedora 14, Ubuntu 14.04
Posts: 434
Blog Entries: 1

Rep: Reputation: 55
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.
 
Old 09-24-2003, 03:53 AM   #3
whansard
Senior Member
 
Registered: Dec 2002
Location: Mosquitoville
Distribution: RH 6.2, Gen2, Knoppix,arch, bodhi, studio, suse, mint
Posts: 3,304

Rep: Reputation: 65
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.
 
Old 09-24-2003, 04:06 AM   #4
myunicom
LQ Newbie
 
Registered: Sep 2003
Posts: 14

Original Poster
Rep: Reputation: 0
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 ?)
 
Old 09-24-2003, 04:10 AM   #5
shawnchin
LQ Newbie
 
Registered: Sep 2003
Location: Malaysia
Distribution: Redhat, Gentoo
Posts: 18

Rep: Reputation: 0
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
 
Old 09-24-2003, 04:18 AM   #6
myunicom
LQ Newbie
 
Registered: Sep 2003
Posts: 14

Original Poster
Rep: Reputation: 0
Thank you !

From myunicom
 
Old 09-24-2003, 08:15 AM   #7
whansard
Senior Member
 
Registered: Dec 2002
Location: Mosquitoville
Distribution: RH 6.2, Gen2, Knoppix,arch, bodhi, studio, suse, mint
Posts: 3,304

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


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to change the file permission ?? AK prince Slackware 17 08-05-2005 12:16 PM
using chmod to change file permission kiwidoc Linux - Newbie 3 07-25-2004 06:39 AM
chmod 755 won't change file permission. duffboygrim Linux - General 11 04-29-2004 06:17 PM
Cannot Change File Permission dsuratman Linux - Newbie 12 11-03-2003 01:47 PM
File permission display and change in GCC Lord CyKill Programming 1 09-26-2003 07:33 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 02:38 PM.

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
Open Source Consulting | Domain Registration