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 11-25-2007, 09:05 AM   #1
SirTristan
Member
 
Registered: Feb 2006
Distribution: GNU/Linux
Posts: 54

Rep: Reputation: 15
Using cp to copy directory permissions recursively?


I'm using 'cp -r /pathto/dir .' to copy /dir to another directory (while logged in as root). Right now the permissions of the new directory aren't matching up with the permissions or ownership of the old directory.

Is there any way to copy the permissions recursively as well?
 
Old 11-25-2007, 09:20 AM   #2
dxqcanada
Member
 
Registered: Sep 2006
Location: Canada
Distribution: Gentoo
Posts: 702

Rep: Reputation: 43
The man page for cp states:

-p same as --preserve=mode,ownership,timestamps

--preserve[=ATTR_LIST]
preserve the specified attributes (default: mode,ownership,timestamps), if possible additional attributes: links, all
 
Old 11-25-2007, 09:25 AM   #3
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Take a look at cp -p and cp --preserve. Note that you can't create a copy with more permissions than you have on the file. For example, copying the file as root may give different results than when copying under <username>

EDIT: I type (and think) slowly--another smart person just beat me to the punch...
 
Old 11-25-2007, 09:36 AM   #4
SirTristan
Member
 
Registered: Feb 2006
Distribution: GNU/Linux
Posts: 54

Original Poster
Rep: Reputation: 15
Thanks for the quick responses, -rp worked
 
  


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
How to Recursively Set Permissions for Directories Only edwin11 Linux - Software 4 12-30-2005 10:54 AM
Setting permissions recursively ojbyer@usa.net Linux - General 4 12-15-2005 08:24 PM
trying to recursively copy jpegs DJOtaku Linux - General 10 08-26-2005 02:09 PM
recursively copy php.ini to www directories osio Programming 3 07-01-2005 05:24 AM
Changing owner of a directory recursively? fturcic Linux - General 2 02-01-2005 08:13 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:22 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