Friday, July 3, 2009

Archive and Compress Files Using zip

Zip and unzip are two free command line programs that comes with Linux. For Windows, they can be downloaded from the Info-ZIP Website. This article provides the basic of archiving and compressing files using the command line zip program.

Zip one file

zip file_to_compress

Zip multiple files

zip file_to_compress1 file_to_compress2 file_to_compress3

Compression options

The compression level ranges from 0 to 9. Level 0 means no compression, 1 compress faster, and 9 compress better. The default is 6.
zip -9 file_to_compress

Password protect zip archive

zip -P the_password file_to_compress

To be prompted for password instead of specifying the password in the command line, use -e instead of -P.
zip -e file_to_compress
Enter password:
Verify password:

Unzip files


Unzip files with informations (verbose mode)

unzip -v

List files that will be unzipped

unzip -l

Test Files That Will Be Unzipped

unzip -t