GO KALI FREE
Compression Commands

zip Linux Command

Creates a compressed ZIP archive of files and directories.

What does zip do?

Creates a compressed ZIP archive of files and directories.

Syntax

zip [options] archive.zip files

Practical example

zip -r project.zip ./myproject

Questions about zip

How do I create a zip archive?

Use `zip archive.zip file1 file2` to create a zip archive containing the specified files.

How do I zip a directory recursively?

Use `zip -r archive.zip directory/` to include all files and subdirectories. The `-r` flag is essential for directories.

How do I extract a zip file?

Use `unzip archive.zip` to extract. Use `unzip archive.zip -d /path/` to extract to a specific directory.

How do I add files to an existing zip?

Use `zip archive.zip newfile.txt` to add new files to an existing zip archive.

How do I list contents of a zip file?

Use `unzip -l archive.zip` to list all files in the zip without extracting.

How do I exclude files from a zip?

Use `zip -r archive.zip directory/ -x '*.log'` to exclude files matching a pattern.

How do I encrypt a zip file?

Use `zip -e -r archive.zip directory/` to create a password-protected zip. You will be prompted for a password.

How do I test a zip file for errors?

Use `unzip -t archive.zip` to test the integrity of the zip file without extracting.

Related Compression Commands

bunzip2

Decompresses a .bz2 file back to its original form.

unzip

Extracts files from a ZIP archive.

bzip2

Compresses files using the bzip2 algorithm (better compression than gzip, slower).

xz

Compresses files using the xz (LZMA2) algorithm — very high compression ratio.

gunzip

Decompresses a .gz file back to its original form.

unxz

Decompresses a .xz file back to its original form.