Linux Terminal Command: zip
The zip command is an essential tool in File Manipulation & Viewing. In this tutorial, we will explore what zip does, look at everyday examples, and cover advanced options to supercharge your command-line workflow.
Concept & Explanation
The zip command bundles and compresses files. It is the standard archive format on Windows systems and is widely compatible.
Common Options & Syntax
zip [options] [arguments]
Here are the most common flags used with zip:
- Simple Usage: Basic default commands.
- Detailed View: Shows diagnostic information.
- Advanced Actions: Can chain parameters for scripting.
1. Interactive Example (Simple)
Here is how most people run the command:
# Example
zip backup.zip report.doc image.png
What it does: Packages ‘report.doc’ and ‘image.png’ into a compressed archive named ‘backup.zip’.
2. Power-User Example (Advanced)
For scripting and advanced diagnostics, use this configuration:
# Advanced
zip -r -e -9 secure_archive.zip ./project
What it does: Recursively (-r) packages the ‘./project’ directory at maximum compression (-9) and encrypts the archive with a password prompt (-e).
⚙️ Warning & Common Pitfalls
[!WARNING] If you zip a directory without the
-r(recursive) flag,zipwill only archive the empty directory directory pointer itself, leaving out the files inside.
🔗 Related Commands
Here are some related posts on cli_tty1 you might want to check out: