Skip to content

zip command

Create .zip archives, and extract them with unzip.

On this page

Syntax

zip [options] archive.zip file…unzip [options] archive.zip [-d dir]

Provided by the zip, unzip package. Run man zip for the full manual.

Common options

OptionWhat it does
zip -rAdd directories recursively
zip -eEncrypt with a password
zip -x PATTERNExclude files
unzip -d DIRExtract into DIR
unzip -lList the contents
unzip -oOverwrite without asking
unzip -qQuiet

Examples

  1. Zip a directory

    zip -r site.zip public_html/
  2. Zip with a password

    zip -er secret.zip docs/
  3. Exclude files

    zip -r app.zip app/ -x "*.git*" "node_modules/*"
  4. Extract a zip

    unzip archive.zip
  5. Extract into a directory

    unzip archive.zip -d /opt/app
  6. List the contents

    unzip -l archive.zip
  7. Extract and overwrite

    unzip -o update.zip

zip guides

← All Linux commands · Suggest a fix

Back to top