View Light

RE: RE: RE: Those pesky tar/gz files!

Parent Message
> One thing that has thrown me for a loop getting into Linux is how the heck to install these compressed archived (Think ZIPped files in NT)???!!

I'd be happy to explain a bit about it.  I don't claim to know everything about everything, (yet :) but file compression, even from a user standpoint, has always been an interest of mine.

> Even worse, some of them are GZ'd (GNU-Zipped) and then contain nothing but a TAR file. I am still so new to this, that it seems kinda stupid. Why TAR and GZ all together?? Oh well, I know how to work with them if I don't understand why...

Well, let's compare this.  Tar is an archiver, and gzip is a compressor.  In the DOS/Windows world, these things are one and the same (pkzip, winzip, whatever.)

When you zip a bunch of files, what it does is it archives a bunch of files together, compressing each one individually.

This is equivalent to gzipping all of the files, and then tarring them all together.

It's much easier (when you have two separate commands) to just tar all the files and gzip them together.  Also, it allows you to compress redundant information between files.  Therefore, using TAR+GZIP on source code should get you better compression than just using PKZIP.

To test this, you can also use PKZIP on zero compression (archiver) and then compress this with PKZIP on maximum compression (compressor).

That's the difference.

> Imagine you have one of these files. Pretend that it is called WeirdThing004.gz

That means the file name got mangled, downloading it dropped the tar extension.

> To extract it, type the following:
>
> gunzip WeirdThing004.gz; tar -xvf WeirdThing004
>
> This will unZip the GZ and then unTar the extracted contents. (This is one of the real nice things Linux has on NT - you can have multiple commands on one line
> - just separate them with a semicolon!!)

It's better than that, actually.  Unix allows you to pipe commands, too.  DOS/Windows does this too, but Unix does it better.  :)

You could also type this:

gzip -dc WeirdThing004.gz | tar -xvf -

This does the same thing, except it uncompresses the file to stdout, and tar untars it from stdin, so you never waste the disk space equal to (GZ_FILE_SIZE - TAR_FILE_SIZE)

Another way to do this would be:

zcat WeirdThing004.gz | tar xvf -

Or if you're using GNU TAR, just do this:

tar xzvf WeirdThing004.gz

It's all the same thing.

> Typically you will have a RunME or Setup file inside the newly extracted contents. Run that to install it. (It's up to you to figure out what to actually do
> with the mess of files you just extracted, it doesn't seem to be de facto standardized like NT is with setup.exe to install things) Also not that Linux is kind
> weird about running program: even if you are in the proper directory (folder) that the executable file is located in, you still have to put "./" in front of
> the file to get it to run. Once again, I have no idea why, yet another stupid-seeming tweak of Linux.
>
> For example, if you are in the directory with a program called CoolGame, you need to type the following to get it to run:
>
> ./CoolGame
>
> I have no idea WTF is with that, but it'll sure save you some headscratching if you know that ahead of time! :)

That's because . (the current directory) isn't automatically in your path, as it is in DOS/Windows.

This is for security reasons, because if root typed 'ls', and there was a compromised ls binary in his current working directory, and '.' was in his path, he would run that, and end up compromising his security instead of running /bin/ls, which is almost certainly what he meant to do.

Since DOS is always run as root, and Windows doesn't know any better, this is a non-issue there.  To 'fix' this as a non-root user, put '.' in your path.

To fix this as a root user, install your (trusted) binaries into directories in your (and maybe everyone else's) path.  (/usr/bin, maybe /usr/local/bin, possibly /usr/local/games, whatever.)

Hope this helps,

Peter Baylies
Rating: (You must be logged in to vote)
Reply
This site contains copyrighted material the use of which has not always been specifically authorized by the copyright owner. We are making such material available in our efforts to advance understanding of environmental, political, human rights, economic, democracy, scientific, and social justice issues, etc. We believe this constitutes a 'fair use' of any such copyrighted material as provided for in section 107 of the US Copyright Law. In accordance with Title 17 U.S.C. Section 107, the material on this site is distributed without profit to those who have expressed a prior interest in receiving the included information for research and educational purposes. For more information go to: http://www.law.cornell.edu/uscode/17/107.shtml . If you wish to use copyrighted material from this site for purposes of your own that go beyond 'fair use', you must obtain permission from the copyright owner.