LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 08-13-2008, 12:33 PM   #1
linuxfia
Member
 
Registered: Apr 2008
Distribution: ubuntu 7.10, centos 4 & 5
Posts: 84

Rep: Reputation: 15
Keeping owner info when moving a directory


I need to rename a directory.
ex) rename "bye" to "hello".
And I'd like to keep the owner:group (and the permissions as well if possible) info. of the "bye" directory and its contents after it's renamed to "hello".

Is this possible?

Thanks.
 
Old 08-13-2008, 12:40 PM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,636

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by linuxfia View Post
I need to rename a directory.
ex) rename "bye" to "hello".
And I'd like to keep the owner:group (and the permissions as well if possible) info. of the "bye" directory and its contents after it's renamed to "hello".

Is this possible?
Yes. Check out the man page for cp. I think the --preserve option is what you're looking for.
 
Old 08-13-2008, 04:12 PM   #3
linuxfia
Member
 
Registered: Apr 2008
Distribution: ubuntu 7.10, centos 4 & 5
Posts: 84

Original Poster
Rep: Reputation: 15
Thanks, the --preserve flag worked like a charm.
 
Old 08-13-2008, 09:11 PM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
What's wrong with 'mv' ?
 
Old 08-14-2008, 11:12 AM   #5
linuxfia
Member
 
Registered: Apr 2008
Distribution: ubuntu 7.10, centos 4 & 5
Posts: 84

Original Poster
Rep: Reputation: 15
Actually I needed to keep the old directory so used cp.
I should've said copy not rename in my post.
 
  


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
nfs change owner during wwrite to directory vgulch Linux - Server 1 01-25-2008 03:57 AM
Get the owner of a directory frayja Linux - Software 3 08-31-2007 01:49 PM
can't change owner of directory miner49er Linux - Networking 1 05-04-2006 03:58 PM
Owner of file in shared directory changing Gunbunny Linux - General 4 01-13-2006 07:00 PM
Changing owner of a directory recursively? fturcic Linux - General 2 02-01-2005 07:13 AM

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

All times are GMT -5. The time now is 10:23 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
Open Source Consulting | Domain Registration