:I don't know, but is there anyway to extract files from a tar file to
:a different directory than the default one? If I'm not wrong, possibly
:I did it before ... (I got a bad memory).
:Like ... I did backup my users home directory ...
:#tar cvf /backup/backup.tar /export/home
:now, I want to exctact the files in different folder rather that in
:/export. How do I do it, please?
GNU tar will, by default, delete the leading '/' from absolute
pathnames, both when creating an archive and when extracting from it.
If your version of tar doesn't do that, one possibility would be to
bring the system down to single-user mode, rename the existing
/export/home to something else, extract from your tar archive, and then
move everything back where it belongs.
It's also possible to set up a chroot environment for running tar, but
doing that is a bit of a PITA. You'll need to have tar and any
libraries it needs within that environment. The archive itself can be
piped in on stdin.
# ldd /bin/tar
libpthread.so.0 => /lib/libpthread.so.0 (0x40025000)
librt.so.1 => /lib/librt.so.1 (0x4003c000)
libc.so.6 => /lib/libc.so.6 (0x4004e000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
# mkdir -p /tmp/tdir/lib /tmp/tdir/bin
# cp /lib/libpthread.so.0 /lib/librt.so.1 /lib/libc.so.6 /lib/ld-linux.so.2 /tmp/tdir/lib
# cp /bin/tar /tmp/tdir/bin
# chroot /tmp/tdir /bin/tar -xvf - </backup/backup.tar
Your files will now be in /tmp/tdir/export/home.