This page looks best with JavaScript enabled

How to work with ZIP archives on GNU/Linux

 ·  ☕ 1 min read

ZIP is a popular archive file format that supports lossless data compression. A .zip file may contain one or more files or directories. zip utility is used to compress file(s) and unzip to extract.

Usage

  • Create a .zip archive from file(s):

    zip archive.zip file1 file2
    

    Use -m to delete source file(s).
    Use -r to compress folder(s).
    Use -e to encrypt archive.

  • Create a .zip archive from file, while specifying the compression level (1 being worst, 9 best, and 6 default). For example, level 7:

    zip -7 archive.zip file1
    
  • Extract file(s) from archive:

    unzip archive.zip
    
  • Extract file(s) to specific directory:

    unzip archive.zip -d /home/$USER/Documents
    
  • Extract file(s) from archive to stdout:

    unzip -p archive.zip
    
  • List all files in archive.zip:

    unzip -l archive.zip
    

    Use -v for verbose output.

  • Add file(s) to archive:

    zip -u archive.zip file3 file4
    
  • Remove file(s) from archive:

    zip -d archive.zip file4
    
  • Test compressed archive data:

    unzip -t archive.zip
    

All Options

You can find all zip and unzip options in man pages:

man zip
man unzip

Vladislav Pashinskikh
WRITTEN BY
Vladislav Pashinskikh
DevOps Engineer, GNU/Linux enthusiast, FOSS and privacy activist from Ukraine