[SunHELP] moving directories
Brian Hechinger
sunhelp at sunhelp.org
Thu Nov 30 12:37:06 CST 2000
> I know I've seen some tar or cpio commands with some piping that would
> work. Since I'm not that proficient, I usually tar up the old directory to
> a file and untar it to the new directory. That works fine if you've got
> the drive space.
cd /dir_to_move_from
tar -cvf - directory_to_move | (cd /directory_to_move_to; tar -xvf -)
the v isn't needed, but let's you see what's going on. bad over a serial
console link.
> Oh, one gotcha here as well... I believe it was Solaris 2.6 I got bit with
> once. Tar'ing as root would not preserve ownership (or was it mv?) I
> found a patch for that however...
if you want to preserve ownership, just add the p flag to tar:
tar -cvpf - directory_to_move | (cd /directory_to_move_to; tar -xvpf -)
make sure you have the correct permissions to do so however (you own everything
involved or you are root)
here's a snippet out of the man page from tar on Solaris 2.x:
p Restore the named files to their original modes, and
ACLs if applicable, ignoring the present umask(1).
This is the default behavior if invoked as super-user
with the x function letter specified. If super-user,
SETUID and sticky information are also extracted, and
files are restored with their original owners and per-
missions, rather than owned by root. When this func-
tion modifier is used with the c function, ACLs are
created in the tarfile along with other information.
Errors will occur when a tarfile with ACLs is extracted
by previous versions of tar.
cheers,
-brian
More information about the SunHELP
mailing list