Hello All,
I've tried a few different things, and i can't seem be able to untar a
file into
a different directory. It always untars to the same structure as is
within the tar.
So i tarred up /etc on a remote machine, and when i untar it on my
local machine
it overwrites my exsisting local /etc rather then untar in the current
/tmp directory
Thanks,
|
|
0
|
|
|
|
Reply
|
lancerset (45)
|
5/15/2006 9:17:58 PM |
|
In article <1147727878.390791.106310@i39g2000cwa.googlegroups.com>,
onlineviewer <lancerset@gmail.com> wrote:
>Hello All,
>
>I've tried a few different things, and i can't seem be able to untar a
>file into
>a different directory. It always untars to the same structure as is
>within the tar.
>So i tarred up /etc on a remote machine, and when i untar it on my
>local machine
>it overwrites my exsisting local /etc rather then untar in the current
>/tmp directory
1) star by default strips off leading slashes on extract
2) star -x -s/from/to/
--
EMail:joerg@schily.isdn.cs.tu-berlin.de (home) J�rg Schilling D-13353 Berlin
js@cs.tu-berlin.de (uni)
schilling@fokus.fraunhofer.de (work) Blog: http://schily.blogspot.com/
URL: http://cdrecord.berlios.de/old/private/ ftp://ftp.berlios.de/pub/schily
|
|
0
|
|
|
|
Reply
|
js
|
5/15/2006 9:26:05 PM
|
|
onlineviewer wrote:
> So i tarred up /etc on a remote machine, and when i untar it on my
> local machine
> it overwrites my exsisting local /etc rather then untar in the current
> /tmp directory
You should use relative paths when creating a tar file, e.g.
cd /etc; tar cf filename.tar .
or
tar cf filename.tar etc (not /etc)
and always check the paths in the tar file before untarring
so that you know where the files are going to go.
tar tf filename.tar
|
|
0
|
|
|
|
Reply
|
Oscar
|
5/15/2006 9:44:39 PM
|
|
onlineviewer wrote:
> Hello All,
>
> I've tried a few different things, and i can't seem be able to untar a
> file into
> a different directory. It always untars to the same structure as is
> within the tar.
> So i tarred up /etc on a remote machine, and when i untar it on my
> local machine
> it overwrites my exsisting local /etc rather then untar in the current
> /tmp directory
>
> Thanks,
>
gtar if you have it (Companion CD/DVD) does remove leading / from archives.
$ /opt/sfw/bin/gtar cvf /tmp/hej.tar /tmp/hej
gtar: Removing leading `/' from member names
/tmp/hej/
/tmp/hej/hej
../J�rgen ;-)
|
|
0
|
|
|
|
Reply
|
Jorgen
|
5/15/2006 10:20:50 PM
|
|
Jorgen Moquist wrote:
> onlineviewer wrote:
>
>> Hello All,
>>
>> I've tried a few different things, and i can't seem be able to untar a
>> file into
>> a different directory. It always untars to the same structure as is
>> within the tar.
>> So i tarred up /etc on a remote machine, and when i untar it on my
>> local machine
>> it overwrites my exsisting local /etc rather then untar in the current
>> /tmp directory
>>
>> Thanks,
>>
> gtar if you have it (Companion CD/DVD) does remove leading / from archives.
>
> $ /opt/sfw/bin/gtar cvf /tmp/hej.tar /tmp/hej
> gtar: Removing leading `/' from member names
> /tmp/hej/
> /tmp/hej/hej
>
> ./J�rgen ;-)
sorry forgot to list it.
$ tar tvf /tmp/hej.tar
-rwxr-xr-x 1000/10 0 May 16 00:17 2006 tmp/hej/
-rw-r--r-- 1000/10 0 May 16 00:17 2006 tmp/hej/hej
../J�rgen
|
|
0
|
|
|
|
Reply
|
Jorgen
|
5/15/2006 10:23:48 PM
|
|
thanks all,,,
|
|
0
|
|
|
|
Reply
|
onlineviewer
|
5/16/2006 12:10:21 AM
|
|
I've also been bitten by this problem. Oscar mentioned the relative
paths solution earlier; I like to use a relative path from the root
directory when I tar something up, then take care on the un-tar to cd
to another directory before un-tar-ing. That way it preserves the
directory structure as well. Probably 6 of one, 1/2 dozen of the other,
but this is how I was able to keep is straight in my mind. And his
advice about always tar-ing with the -t option to see the actual
contents BEFORE actually extracting the files is spot-on; been bitten
by THAT before, too! :~)
Source machine:
cd /
tar -cf tarfile ./etc
Target machine:
cd /
tar -xf tarfile # re-creates ./etc relative to your current
directory (in this case, the root directory)
- or -
cd /tmp
tar -xf tarfile # re-creates ./etc under the /tmp directory, leaving
original /etc alone
Joe D.
|
|
0
|
|
|
|
Reply
|
Joe
|
5/16/2006 12:59:09 PM
|
|
pax -r -s ',^/,,' -f <tarfile>
-Raf
|
|
0
|
|
|
|
Reply
|
raf
|
5/16/2006 1:59:36 PM
|
|
Joe D. wrote:
> cd /tmp
> tar -xf tarfile # re-creates ./etc under the /tmp directory, leaving
> original /etc alone
careful there too... some tar files might include "." which might
mess up the permissions of your current directory (/tmp) if running
as root
|
|
0
|
|
|
|
Reply
|
Oscar
|
5/16/2006 3:00:09 PM
|
|
I was sent a tar file to look at the other day, a tar of /etc/ssh.
tar tf showed me that explicit file names were used.
So I copied the tar file to a box where the ssh directories were all
under /usr/local, and untarred it safely into /etc.
Since I can't think of any flavors of unix that don't have /etc,
perhaps you could untar the blob on a Windows box?
-Mike
|
|
0
|
|
|
|
Reply
|
hubcap
|
5/16/2006 3:04:07 PM
|
|
In article <e4cpl7$plj$1@hubcap.clemson.edu>,
hubcap <hubcap@clemson.edu> wrote:
>
>
>I was sent a tar file to look at the other day, a tar of /etc/ssh.
>
>tar tf showed me that explicit file names were used.
>
>So I copied the tar file to a box where the ssh directories were all
>under /usr/local, and untarred it safely into /etc.
>
>Since I can't think of any flavors of unix that don't have /etc,
>perhaps you could untar the blob on a Windows box?
>
>-Mike
From "man chroot" on Solaris 9:
EXAMPLES
Example 1: Using the chroot utility.
The chroot utility provides an easy way to extract tar files
(see tar(1)) written with absolute filenames to a different
location:
example# cp /usr/sbin/static/tar /tmp
example# dd if=/dev/nrst0 | chroot /tmp tar xvf -
Note that tar is statically linked, so it is not necessary
to copy any shared libraries to the newroot filesystem.
|
|
0
|
|
|
|
Reply
|
ted
|
5/16/2006 3:39:07 PM
|
|
I have been bitten by this exact thing; extracted a file in /tmp that
changed the permissions and broke just about EVERYTHING!
Gotta be careful with that one, especially when untarring a file that
you didnt tar in the first place. I always use 'tar tvf' first to
find out how the file was tarred.
|
|
0
|
|
|
|
Reply
|
tonij67
|
5/16/2006 3:40:08 PM
|
|
I expect this guy is the winner. Thanks Ted...
Some of the other ideas were winners too, but everyone doesn't
have star (for example) lying about already.
-Mike
ted@loft.tnolan.com (Ted Nolan <tednolan>) writes:
>From "man chroot" on Solaris 9:
>EXAMPLES
> Example 1: Using the chroot utility.
> The chroot utility provides an easy way to extract tar files
> (see tar(1)) written with absolute filenames to a different
> location:
> example# cp /usr/sbin/static/tar /tmp
> example# dd if=/dev/nrst0 | chroot /tmp tar xvf -
> Note that tar is statically linked, so it is not necessary
> to copy any shared libraries to the newroot filesystem.
|
|
0
|
|
|
|
Reply
|
hubcap
|
5/16/2006 4:04:54 PM
|
|
|
12 Replies
1374 Views
(page loaded in 0.17 seconds)
|