Use GNU tar.
From manual page:
<eaten> -P --absolute-names Do not strip leading slashes from file names. By default, GNU tar drops a leading `/' on input or output. This option turns off this behavior; it is equivalent to changing to the root directory before running tar (except it also turns off the usual warning message). When tar extracts archive members from an archive, it strips any leading slashes (`/') from the member name. This causes absolute member names in the archive to be treated as relative file names. This allows you to have such members extracted wherever you want, instead of being restricted to extracting the member in the exact directory named in the archive. For example, if the archive member has the name `/etc/passwd', tar will extract it as if the name were really `etc/passwd'. <eaten> Also call tar using full pathname, because just 'tar' may be aliased to 'tar -P' Hope that will help. -- Alex On Thu, 16 May 2002, Clayton Cornell wrote:
Date: Thu, 16 May 2002 20:09:10 +0200 From: Clayton Cornell <c.cornell@chello.nl> To: suse-linux-e@suse.com Subject: Re: [SLE] tar question
On Thursday 16 May 2002 18:15, Anders Johansson wrote:
On Thursday 16 May 2002 17.08, Clayton Cornell wrote:
Typed in gtar -x file.tar and it woudl just sit there blinking at me until I Ctrl-C'ed it..
tar -x will take its input from standard input. That "blinking at you" was just tar waiting for data from the command line. ctrl-c killed it, but so would ctrl-d (end of file). You need tar -xf file.tar
regards Anders
Agreed, tar -xf file.tar would extract the tarfile, and has many times for me on my home system. For this situation, I want to untar the file on a system I do not have root access to, and cannot get root access to - not permitted or negotiable due to strict security on this system. I can only work in /home/<username> and /usr/local/ The tarfile I have was created by someone else and it wants to extract to /opt - a directory that exists, but is root write access only.
The question is, can I force tar to ignore the leading '/' and extract to, for example: /home/clayton/temp thereby building the directory structure: /home/clayton/temp/opt/<tarred files and directories> instead of: /opt/<tarred files and directories> that it tries to do when I type tar xvf file.tar (and subsequently bounces off the readonly permissions of /opt saying that I do not have permission to write to /opt... which I don't)?
Christopher suggested 'tar xf opt.tar' will strip the leading '/'
Now, I may be having a senior moment/brain fart, but to me, tar xf opt.tar tells tar to extract the tar file opt.tar. The v option I like to use is for verbose so I can see what is happening and where everthing is magically being put.
I experimented a bit with this idea, and just on a whim tried tar xf file.tar opt.tar to see if maybe this is what Christopher meant. Tar hummed along, appearing to do something, and returned the command prompt after about 30 seconds - no errors reported. I was thinking maybe this would create the file opt.tar with the leading '/' removed. It actually did nothing I could see. No opt.tar (not that I really expected it based on what I read in the man pages) and file.tar is still looking to put everything in /opt.
Greg suggested I use chroot, but that is not an option... no root access, and chroot is a root command.
Alexandr suggested a possible bug, but I don't agree. Tar is doing what it is supposed to do, untarring to the directory structure it was created with... I want to override that. I'm the bug here ;-)
So, that about sums up the various responses so far. I get the feeling I am going to have to hunt down a machine I have root access to (ie my own computer at home) and extract the file there and rebuild the tar file without the leading '/'. A poor option because I don't always have the home system easily available.
C.
-- To unsubscribe send e-mail to suse-linux-e-unsubscribe@suse.com For additional commands send e-mail to suse-linux-e-help@suse.com Also check the archives at http://lists.suse.com