Learn how to create, extract, and list files within a compressed zip archive in Secure Shell (SSH), or cPanel Terminal, with the zip and unzip commands.

  • Create an archive
  • Extract Files
  • List Archived Files

Spend more time working on your website than setup with our Shared Business Hosting – Softaculous Instant Installer and WP-CLI ready to go.

Compress Files

Use the zip command to manage compressed files.

zip -r archive-name.zip path-to-directory-or-files

Example: zip -r images.zip *.png – Archive all PNG image files in the current directory into a images.zip file
Example: zip -r backup.zip * – Archive all files and folders in the current directory into a backup.zip file

Used options:

-r – Travel the directory structure recursively

Decompress Files

Instead of zip, use the unzip command to manage compressed files.

unzip archive.zip

Example: unzip images.zip

Extract to Another Directory

unzip archive.zip -d another-folder

Example: unzip images.zip -C restored – Extract files from the images.zip file into the existing /restored folder

Used options:

-d – Specify directory

List Files

unzip -l archive.zip

Used options:

-l – list archived files

For more options, type the zip --help or unzip --help command.