tar cvf mytarfile.tar /etc...because when you untar it on your destination, regardless of the present directory, it will overwrite everything in /etc! What a way to spoil your day. Always, always use relative path targets for Solaris' tar.
cd /etc
tar cvf mytarfile.tar .Get in the habit of always displaying the tar file's contents first:
tar tvf mytarfile.tar...and never unpack it if it begins with a slash!
If you have such a tar file, what do you do now?
/usr/bin/cp /usr/sbin/static/tar /tmp
/usr/bin/dd if=file.tar | /usr/bin/chroot /tmp ./tar xf -...and your output will be safely unpacked in /tmp. Yes, you have to be that anal about it.
Fortunately, this is not a problem with GNU tar in Linux and other OS's; the path is always relative. But you could still muck up things if you are in / when you unpack!
Be careful out there.

2 comments:
Wow. That was handy! Exactly what I needed. Thanks!
good article. For more examples on tar command:tar command examples in unix
Post a Comment