[Gllug] File permissions

Nix nix at esperi.demon.co.uk
Sun Sep 9 21:41:18 UTC 2001


On Sun, 9 Sep 2001, Gordon Joly uttered the following:
> I tend to use tar(1); something like
> 
> tar cvf - WHATEVERFILES/DIRSYOUWANT | ( cd NEWPLACE ; tar xf -)

This is not safe. You need at least a p in the untar, or a umask 000 in there.

A totally paranoid method is, say, (using GNU long options to make it
clear what's going on)

(cd source && tar --create --sparse --to-stdout --atime-preserve --preserve --same-owner --numeric-owner .) | (umask 000; cd destination && tar --extract --sparse --atime-preserve --preserve --same-owner --numeric-owner --verbose)

Unlike your suggestion, this preserves file sparseness, uids/gids (even
if your machine's passwd file hasn't been set up properly yet), atimes
(if run as root), and permissions.

(I've used a variant of this to clone entire systems across NFS and/or
netpipes.)

> I think this example is in the manual page.

pax is very good for this:

  pax -rw {files} {destination}

or to preserve permissions

  pax -rw -p eop 

pax's -s option (apply sed s-command transformations to filenames) is
very useful too, I find.

(I must get around to installing pax here...)

-- 
`It's all about bossing computers around. Users have to say "please".
Programmers get to say "do what I want NOW or the hard disk gets it".'
                        -- Richard Heathfield on the nature of programming

-- 
Gllug mailing list  -  Gllug at linux.co.uk
http://list.ftech.net/mailman/listinfo/gllug




More information about the GLLUG mailing list