[Techtalk] 'nother obvious newbie question

Mary Gardiner linuxchix at puzzling.org
Wed Oct 3 09:02:21 EST 2001

On Tue, Oct 02, 2001 at 10:47:26AM -0700, Kai MacTane wrote:
> At 10/1/01 09:29 PM , Rachel Herold wrote:
> >help!
> >okay, I get it installed, how come I can't figure out how to read the dern
> >doc files?  I found a whole set of help files ending in .gz but haven't 
> >been
> >able to figure out how to read/open them.  I've tried all the obvious
> >things, a few non-obvious things (at least non-obvious to a windows 
> >person),
> >but I give up and decided I shouldn't waste so much time (2 hours is 
> >enough)
> >when I can ask someone.
> Ah. What do with a .gz file is fairly obvious to an experienced Unix 
> person... <wry grin> You just do a "tar -xvzf" on the sucker.

Um, no, only if it is also a tar file that has then been gzipped.

For example, if it is Debian-like documentation, which has only been gzipped,
you get an error something like:

$ tar -xzvf manual.txt.gz 
tar: This does not look like a tar archive
tar: Skipping to next header
tar: 260 garbage bytes ignored at end of archive
tar: Error exit delayed from previous errors

because it got as far as unzipping the GZ compression, but then doesn't see a
tar file inside.

This is, in fact, part of the UNIX Way.

When zipping something up in Windows, you use things based on the PKZip
utilities (probably WinZip), which can take one or many files, put them into
one single file *and* compress them. (By the way, there are Linux untilities,
just called zip and unzip, that can deal with these files.)

In UNIX, there is one utility to put all of the files together - tar, and one
to compress them - gzip. tar has a flag -z to be able to be alerted to the
fact that you also want to deal with compression.

So there are three types of extensions that will clue you in:
1) .tgz, or .tar.gz, which means you have Kai's situation with the file that has
been both tarred and gzipped in which case:

>    tar -xvzf file-to-open

> A quick description of just what's going on in that command line is:
> tar: the name of the command that both tars and untars stuff.
>  -x: eXtract a file (other main options are Create and lisT file;
>      see below for more on that)
>  -v: Do it Verbosely (list files as tar is operating; not strictly
>      necessary, but nice to have for some output).
>  -z: Use Zip compression (i.e., if creating a file, compress it in
>      addition to just glomming all the files into one; if extracting
>      or listing, realize that the file was compressed, and use the
>      Zip algorithm to uncompress).
>  -f: What file to act on; must be followed *immediately* by the name
>      of the archive file.

2) .tar, which means you're only dealing with a tar file, in which case, leave
out the z flag:

        tar -xvf file-to-open

3) .gz, which means you're only dealing with a gzipped file - use gunzip, or
if you think it is a text file, zless, just to have a peek.

Now to create them:
> The fact that -f must be followed immediately by the name of the archive 
> file is only of importance when you're creating a new archive. In that 
> case, the command line is:
>    tar -cvzf file-to-create  filespec-to-compress

Try to give file-to-create a .tar.gz or .tgz extension, since that won't
happen automatically.

        tar -cvf file-to-create  filespec-to-compress
Try to give file-to-create a .tar extension, since that won't happen

        gzip file-to-compress
This will add a .gz to the file name itself, but it will also delete the
original file and leave you with only the compressed copy.


Mary Gardiner
<mary at puzzling.org>

More information about the Techtalk mailing list