Access Keys:
Skip to content (Access Key - 0)

How can I archive or compress files on Athena?

On this page:

Overview

The two most popular archive formats in use are gzipped tar files (.tar.gz or .tgz) and zip files (.zip). While there are many other formats, these formats are the most popular and can be read on the widest variety of operating systems.

Zip files can be decompressed automatically by Windows XP and higher, and Mac OS X. .tar.gz files can be decompressed automatically on Mac OS X, but Windows users will require additional software such as the free 7-Zip (http://www.7-zip.org) or a trial version of WinZip (www.winzip.com).

ZIP files

You can create .zip files with the "zip" command. For example, to create "archive.zip" containing the files "1.txt", "2.txt", and "3.txt" (assuming they are in the current directory), you would use the following command:

joeuser@athena:~$ zip archive.zip 1.txt 2.txt 3.txt
  adding: 1.txt (deflated 54%)
  adding: 2.txt (deflated 83%)
  adding: 3.txt (deflated 26%)

Alternatively, if you want to create a zip file of your personal web site, you can use:

joeuser@athena:~$ zip -r website.zip ~/www

  

That will compress the www directory and all its contents into the website.zip file. If you omit the "-r" option to zip, you will end up with an empty ZIP file, since it will add the entry for the directory, but none of its contents.

ZIP files can be uncompressed with the "unzip" command. Simply typing "unzip filename.zip" will usually produce the desired behavior, which is to extract the file into the current directory.

For more information, type "man zip" and "man unzip"

tar.gz files

Creating tar.gz files is actually a two step process - first you are creating a tar (which stands for "Tape ARchive") file, and then you are compressing it.

To create a tar file of your "www" directory:

joeuser@athena:~$ tar -cvf archive.tar ~/www

  

The -cvf options to tar instruct it to create an archive (c), be verbose by displaying every filename as it's added (v), and that you wish the archive to be saved to a file (f) called archive.tar.

Once the .tar file has been created, you can compress it with "gzip":

joeuser@athena:~$ gzip archive.tar

  

This will change the filename to "archive.tar.gz" and compress the file.

The GNU version of tar (found on Linux systems and most other modern UNIX operating systems) can do the gzip compression automatically, by adding "z" to the list of tar options:

joeuser@athena:~$ tar -czvf archive.tar.gz ~/www

  

However, not all versions of tar support the GNU extensions, so you may need to use the two-step procedure described above.

To extract .tar.gz files into the current directory, you first decompress the archive with the "gunzip" command, and then extract it:

joeuser@athena:~$ gunzip archive.tar.gz
joeuser@athena:~$ tar -xvf archive.tar

  

Once again, GNU tar users can combine this into one step:

joeuser@athena:~$ tar -xzvf archive.tar.gz

  

Other archive formats

It may be possible to create and extract other archive formats on Athena, but the formats listed above are the only supported ones. The following table lists additional formats that we're aware of, but we cannot guarantee that they will work:

Format Extension Compression Program Extraction Program
Compress .Z compress uncompress
Frozen .F freeze (sipb locker) melt (sipb locker)
BinHex .hqx (n/a) xbin (consult locker)
Roshal Archive .rar (n/a) unrar (outland locker)

IS&T Contributions

Documentation and information provided by IS&T staff members


Last Modified:

December 15, 2010

Get Help

Request help
from the Help Desk
Report a security incident
to the Security Team
Labels:
olc-unix olc-unix Delete
archive archive Delete
compress compress Delete
zip zip Delete
athena athena Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
Feedback
This product/service is:
Easy to use
Average
Difficult to use

This article is:
Helpful
Inaccurate
Obsolete
Adaptavist Theme Builder (4.2.3) Powered by Atlassian Confluence 3.5.13, the Enterprise Wiki