How to zip/unzip on the unix command line

command linezip

How can I create and extract zip archives from the command line?

Best Answer

Typically one uses tar to create an uncompressed archive and either gzip or bzip2 to compress that archive. The corresponding gunzip and bunzip2 commands can be used to uncompress said archive, or you can just use flags on the tar command to perform the uncompression.

If you are referring specifically to the Zip file format, you can simply use the zip and unzip commands.

To compress:

zip squash.zip file1 file2 file3

or to zip a directory

zip -r squash.zip dir1

To uncompress:

unzip squash.zip

this unzips it in your current working directory.

Related Question