Skip to main content

Zip

The zip command is used to compress files into a .zip archive. Here's a basic overview of how to use it:

  1. Basic syntax
zip archive_name.zip file1 file2 file3
zip archive_name.zip *

This will create a zip archive called archive_name.zip that contains file1, file2, and file3.

  1. Including directories

If you want to include directories, you can use the -r (recursive) option:

zip -r archive_name.zip directory_name

This will zip the directory and all its contents, including subdirectories.

  1. Excluding files

You can exclude specific files using the -x option:

zip -r archive_name.zip * -x "*.log"

This will zip all files in the current directory, but exclude any .log files.

  1. Adding files to an existing zip archive

To add files to an existing zip archive, use the -u option:

zip -u archive_name.zip file4 file5
  1. Password-protecting the archive

To add password protection to the zip file, use the -e option:

zip -e archive_name.zip file1 file2

You'll be prompted to enter a password.

  1. Viewing the contents of a zip file

You can list the contents of a zip file with the -l option:

zip -l archive_name.zip
  1. Compression level

You can control the compression level (from 0 to 9, where 0 is no compression and 9 is maximum compression)

zip -9 archive_name.zip file1 file2
  1. Splite a zip file into smaller parts
zip -s 15m archive_name.zip file

To unzip a zip file, you can use unzip

unzip filename.zip