zip & unzip (File Compression and Extraction)
zip is a compression and file packaging utility for Unix-like systems. It is highly compatible with Windows and other operating systems, making it the best choice for cross-platform file sharing.
1. Basic Usage
zip [options] archive_name.zip target_file
unzip archive_name.zip
2. Key Options
| Command | Option | Description |
|---|---|---|
| zip | -r |
Recursive. Includes all files and subdirectories. |
| zip | -e |
Encrypt. Protects the archive with a password. |
| unzip | -d |
Directory. Extracts files into a specified directory. |
| unzip | -l |
List. Displays the content of the zip file without extracting. |
3. Practical Examples
① Compressing a directory recursively
zip -r project_backup.zip ./src
② Extracting to a specific path
unzip archive.zip -d /home/user/workspace/
③ Checking file list inside a ZIP
unzip -l files.zip
4. [Tip] Compatibility
While tar is the native Linux standard, zip is indispensable for working with non-Linux systems. Note that zip might not preserve advanced Linux permissions as effectively as tar.