mv while retaning permissions?

James Gray james at grayonline.id.au
Mon Sep 19 00:44:32 UTC 2005


On Sunday 18 September 2005 20:06, Pierfrancesco Caci wrote:
> :-> "Senectus" == Senectus  <senectus at gmail.com> writes:
>     > How do you move and retain permissions.
>
> mount the new home partition somewhere temporarily, let's assume it's
> under /newhome
>
> as root(*), do
> cd /home
> tar cvlSp . | (cd /newhome; tar xvf -)

Just a few minor nit-picks on tar (sorry, I know you got picked up on "sudo 
-s" thing) but I think it's worth mentioning for the archives:

"tar cvlSp" being run as root means that the "p" option is redundant for 2 
reasons:
1. As root it's assumed the "p" is assumed.
2. Secondly, the "p" option only has significance when EXTRACTING files :)

The l option is sensible, but the S (handle sparse files efficiently) probably 
wont gain you much when doing this sort of tar-pipe-tar file transfer on 
local file systems....anyone done any benchmarking on this?  I'm happy to be 
proven wrong. :P

Lastly, were you aware that tar (GNU tar at least) has a "-C directory" option 
that will cause tar to change into "directory" before doing the rest of the 
task?  It simplifies the RHS of your pipe to "tar xv -C /newhome".  This 
avoids the need to "cd /foo && tar blah" type syntax, and having the change 
back to your original working directory.  BTW, tar assumes STDIN/STDOUT 
unless the "f" option is used, so using "-f -" is often (usually) 
unnecessary...but old habits can be hard to break ;)

Cheers,

James 
-- 
Some people only open up to tell you that they're closed.




More information about the ubuntu-users mailing list