Decoding Attachments to Emails and other Compressed/Encoded File Formats

A graphical tool file that can pack and unpack various archive formats is called file-roller.

Tarred and Gzipped

Gzip

To gzip a file called foo you use the gzip command as follows

gzip foo

This will produce a file foo.gz. You can specify the compression level with an extra option, for maximum compression use

gzip -9 foo

To unzip a gzipped file use the command gunzip, e.g.

gunzip foo.gz

or use gzip -d

Tar

Tar can be used to combine a set of files into one single file (which you can then gzip). For example suppose you wish to tar the entire contents of a directory (called bar) and all its sub directories then you can do

tar -cvf bar.tar bar

The option c says to create a new archive, the v means we are in verbose mode (so we can see what it is doing) and the f specifies the next thing will be the name of the tar archive. The final argument is the directory we wish to tar, it could have equally been a list of the files we wanted to put in the archive.

If you are given a tar archive you can check its contents with

tar -tvf bar.tar

and you can then extract the contents with

tar -xvf bar.tar

If you are given a tarred and zipped file you can miss out the gunzip step by adding the z option, thus

tar -tvzf bar.tar.gz

will list the contents and

tar -xvzf bar.tar.gz

would extract them. (Note tarred and zipped archive sometimes have the extension .tgz rather than .tar.gz).

Bzipped

Bzip2 is another means of compressing files. It has similar options to gzip but can give better compression. It is however less widely available so may not be a good choice for sharing information with others. It is installed on the Maths network only for the Linux and Alpha machines.

To compress a file with bzip called foo do

bzip foo

to obtain a file called foo.bz2.

To unzip a bzipped file use the command bunzip2, e.g.

bunzip2 foo.bz2

or use bzip2 -d

Compressed

A further compression command is simply compress and results in a file with extension .Z. This is only available on the Suns and Alphas and generally gives the poorest compression. To uncompress a compressed file either use uncompress or gunzip

Zipped

A zip archive is often useful for transfering files from the UNIX system to a Windows PC where they can be extracted using WinZip a shareware packages. To zip up a list of files use a command of the form

zip archive-name.zip file1 file2 ......

To zip up the entire contents of a directory (called bar) and its sub directories do

zip -r bar.zip bar

Again for maximum compression do

zip -9r bar.zip bar

To unzip a zipped file use unzip, e.g.

unzip foo.zip

Uuencoded

Another possibililty is that you may receive an email which says the file is uuencoded. In this case export the message/attachment to say mail.uu.

To decode it simply do

uudecode mail.uu

MS-TNEF

A Microsoft Outlook and Exchange server format. Save the attachment to a file, say mail.tnef and then check its contents with

tnef -l mail.tnef

and then assuming you are happy with the contents extract them with

tnef mail.tnef

Please contact us with feedback and comments about this page. Last updated on 22 Apr 2022 19:59.