Files may be compressed or several files may be archived into a single file and then compressed. In all liklihood, it will end in .z, .Z, .gz, or .zip
To extract a compressed file: (ending of .z or .Z)
uncompress filename
To extract a zipped file: (ending of .zip)
unzip filename
To extract a gzipped file: (ending of .gz)
gunzip filename
gunzip is the GNU software version of unzip. This will uncompress a file if it has been compressed, gzipped, or zipped (if it is a single file). Note that while gunzip recognizes the .z, .Z and .gz extensions, it does not recognize the .zip extension. So if you have a zipped file, you need to rename it to have the .gz extension before gunzip will recognize it. Note if your .zip file includes more than one file, you should use unzip instead. ugunzip can be found in /gnu/bin. If you do not have /gnu/bin in your path, you will need to add it to your PATH environment variable.
Question 2 - How can I tell which utility program "zipped" a file so that I will know what command
to use to "unzip" it?
The suffix on the file name is the key. Here are the various utilities and the suffix each creates. To expand the compressed file, use the command "un<prog> file.key". For example, to
To "zip" Suffix To View To "unzip"
-----------------------------------------------------------------
compress .Z zcat uncompress
gzip .gz zcat gunzip
zoo -add .zoo zoo -extract
zip .zip unzip
Question 3 - How do I extract .tar.Z files?
Files with the suffix .tar.Z are compressed and archived files. For instance, a software package may consist of many files that are archived into a single file called package.tar Then, this tar file is compressed to save memory and is called package.tar.Z
To extract the files from package.tar.Z: Change to the directory where you want to expand the files. Uncompress the file with the command: uncompress package.tar.Z This produces the file package.tar Then restore the archived files in package.tar with the tar command: tar -xvf package.tar Since the files have been uncompressed, they are now taking up a lot more disk space. You may want to delete the .tar file to save space. To compress the files again, use the compress command ( for example: compress -v bigfile will create a compressed file called bigfile.Z) A common way to get the contents of a tarred, compressed file without having to uncompress and then recompress the tar file is as follows: zcat package.tar.Z | tar -xvf -
Question 4 - How do I create and extract a directory archive?
Let's say you had a directory called test. Issue the following commands where the test is the subdirectory.
****To tar and compress the directory test:
tar cf - test | compress > tartest.Z
You may then remove the directory test.
****To view the table of contents of your tar archive, tartest.Z:
zcat tartest.Z | tar tvf -
****To uncompress and untar the tar archive:
zcat tartest.Z | tar xf -
This creates the directory test, with all its files.
The name tartest.Z was used to illustrate that the tar file had been compressed.
Strangely, if you compress the files first, then tar and compress, it takes up MORE room. Some of the excess (beyond
the bytes taken up by the files themselves originally, is that directories take up room, and references to files
take up room. The bottom line is: tar | compress is best.