Here is the scenario.... I need to un-tar an application on a system that I do not have root access to. The tar is setup to extract /opt and I cannot write to that directory. Is there anyway I can redirect the tar to extract to /home/username/opt (or some variation of that directory structure)? C
* Clayton Cornell (c.cornell@chello.nl) [020515 20:48]:
Is there anyway I can redirect the tar to extract to /home/username/opt (or some variation of that directory structure)?
'tar xf opt.tar' will strip the leading '/', even if the archive was created with '-P'. -- -ckm
On Thursday 16 May 2002 06:07, Christopher Mahmood wrote:
* Clayton Cornell (c.cornell@chello.nl) [020515 20:48]:
Is there anyway I can redirect the tar to extract to /home/username/opt (or some variation of that directory structure)?
'tar xf opt.tar' will strip the leading '/', even if the archive was created with '-P'.
Hmmm no success. It still insists on untarring to /opt/appname - unless I misunderstood the instruction above. I tried gtar at work today too (suggestion from someone else) and no success with that either. gtar would do nothing on the tar file. Typed in gtar -x file.tar and it woudl just sit there blinking at me until I Ctrl-C'ed it.. I am beginning to think I will have to untar it on a another machine I have root access to and re-tar it without the leading '/'. Seems odd to me that it is so difficult to override the file path in a tar file. C.
Clayton Cornell
'tar xf opt.tar' will strip the leading '/', even if the archive was created with '-P'.
Hmmm no success. It still insists on untarring to /opt/appname - unless I misunderstood the instruction above.
I just wonder if you talk about SuSE Linux and GNU tar. If yes then it is a bug which should be reported. -- Alexandr.Malusek@imv.liu.se
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 -- I swear I do declare - how did you get that there?
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.
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
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
On Thursday 16 May 2002 20.09, Clayton Cornell wrote:
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.
Indeed, but the fact that you could use "gtar" suggests that Alexander's hunch was correct, you're not on a linux system when you do this, are you? Is it *BSD? Solaris? In any case, try gtar -xf file.tar //Anders -- I swear I do declare - how did you get that there?
On Thursday 16 May 2002 20:13, Anders Johansson wrote:
On Thursday 16 May 2002 20.09, Clayton Cornell wrote:
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.
Indeed, but the fact that you could use "gtar" suggests that Alexander's hunch was correct, you're not on a linux system when you do this, are you? Is it *BSD? Solaris?
Both Linux and Solaris - the gtar was indeed on a Solaris machine. Tar on both. I will give it all a try again tomorrow. Maybe I have finger problems ;-) It has been known to happen with me on many occasions. C.
In any case, try gtar -xf file.tar
//Anders
* Clayton Cornell (c.cornell@chello.nl) [020516 11:08]:
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.
No, I meant run tar xf whatever_your_file_is.tar in a directory that you can write to. It will work, I promise: $ sudo tar cP /bin > bin.tar $ tar tf bin.tar /bin/ /bin/dd /bin/cp : /bin/df /bin/ed : $ mv bin.tar ~/tmp $ tar xf bin.tar tar xf bin.tar tar: Removing leading `/' from member names $ find bin bin bin/dd bin/cp : bin/ps bin/rm bin/sh " -- -ckm
[Clayton Cornell]
[...] can I force tar to ignore the leading '/' and extract to [...]
Unless it changed recently, this is the default option. You need -P to override the behaviour so the leading `/' is not removed.
I experimented a bit with this idea, and just on a whim tried tar xf file.tar opt.tar [...] It actually did nothing I could see.
Use `tar xvf' or `tar xvvf' to see what `tar' is extracting. -- François Pinard http://www.iro.umontreal.ca/~pinard
I always put a . in front of the files/directories I'm tarring. That way you can extract them anywhere you want/can. Chris Geske LIMS Manager Northern Lake Service, Inc. ph: 715-478-2777 email: lims@newnorth.net -----Original Message----- From: Clayton Cornell [mailto:c.cornell@chello.nl] Sent: Thursday, May 16, 2002 1:09 PM 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
Clayton Cornell
Alexandr suggested a possible bug, but I don't agree.
Well, I rather suggested you don't use GNU tar on SuSE Linux because the behavior you describe is typical e.g. for the native tar on Solaris. My experience is that users who are very secretive about versions of their tools and OS often use a commercial Unix and seek help in Linux groups since they know they will get very fast response there. I don't say it's bad but they don't realize the XPG4,... based tools found in commercial Unixes sometimes differ a lot from GNU tools and thus they waste time of people who try to help them. I don't say it is your case, it's just my experience from other e-mail lists. -- Alexandr.Malusek@imv.liu.se
My experience is that users who are very secretive about versions of their tools and OS often use a commercial Unix and seek help in Linux groups since they know they will get very fast response there. I don't say it's bad but they don't realize the XPG4,... based tools found in commercial Unixes sometimes differ a lot from GNU tools and thus they waste time of people who try to help them. I don't say it is your case, it's just my experience from other e-mail lists.
Wasn't attempting to be deliberately secretive. I use Solaris and SuSE Linux daily... to the point I often neglect to differentiate between them. I use KDE on both... use the same basic tools etc. They start to look the same after a while, and I get tied up in the problem and forget that there are some fundamental underlying differences. Gets me into a bit of hassle once in a while. The actual file itself I thought was not a big issue.. it is a non commercial tar file. I had similar behaviour with other tar files that I experimented with under the same conditions. But, like I said in an earlier email, I may be just having finger problems too. I was actually hoping to learn more about the way tar works rather than waste anyone's time. I will chew through it again tomorrow and see what happens. To those that have been bearing with me on this, thanks... much food for thought. I will not harp on about the issue... if it doesn't work for whatever reason, I will untar on my home machine, and move on. Later C.
On Thursday 16 May 2002 4:08 pm, Clayton Cornell wrote:
Hmmm no success. It still insists on untarring to /opt/appname - unless I misunderstood the instruction above. I tried gtar at work today too (suggestion from someone else) and no success with that either. gtar would do nothing on the tar file. Typed in gtar -x file.tar and it woudl just sit there blinking at me until I Ctrl-C'ed it.. I am beginning to think I will have to untar it on a another machine I have root access to and re-tar it without the leading '/'. Seems odd to me that it is so difficult to override the file path in a tar file.
What is your output when you use tar xvf <yourtarfile>?
participants (8)
-
alex@happyroot.org
-
Alexandr Malusek
-
Anders Johansson
-
Chris Geske
-
Christopher Mahmood
-
Clayton Cornell
-
Jonathan Lim
-
pinard@iro.umontreal.ca