How to Compress and Extract Files with zip and unzip
The zip command packs files into a .zip archive and unzip opens them. zip notes.zip notes.txt compresses one file, and unzip notes.zip restores it. Zip archives are the most portable format on the internet, so you will meet them constantly.
Create a zip archive
Give zip the archive name first, then the files. The archive gets a .zip extension automatically if you leave it off.
Zip a whole folder with -r
zip does not descend into folders on its own. Add -r to include everything inside:
List the contents with unzip -l
Before extracting an unknown archive, list what is inside without unpacking it:
Extract a zip
unzip restores the archive into the current directory, recreating folders as needed. Extract to a specific place with -d.
zip vs tar
Use zip when you must share with others or attach to a form. For backups and Linux-to-Linux transfers, tar preserves permissions better. See zip and unzip for the full references.
Keep learning
Related guides: How to Compress and Extract Files with tar · How to Download Files with the Linux wget Command · How to Move and Rename Files with the Linux mv Command. Read all tutorials on the Learn Linux blog.