zip Command in Linux
Build an AI-First Career, Master the Complete Skillset
Choose from our industry-leading programs designed for career success
Modern Software and AI Engineering Program
Master full-stack development with AI integration
+1000 moreModern Data Science and ML with specialisation in AI
Advanced data science techniques with AI specialization
+1000 moreAdvanced AIML with Specialisation in Agentic AI
Deep dive into AIML with focus on Agentic systems
+1000 moreDevOps, Cloud & AI Platform Engineering
Build and manage AI-powered cloud infrastructure
+1000 moreAI Engineering Advanced Certification by IIT-Roorkee
Premier AI engineering certification from IIT-Roorkee
AI Forward Deployed Engineer Program
Full-stack engineering, production AI and client-facing consulting
+1000 moreOverview
The zip command in Linux is a versatile utility for creating, updating, and extracting compressed files and directories. This command is useful for efficiently archiving files and folders, saving storage space, and reducing the time taken to transfer files over the internet.
Linux zip Command Syntax
The syntax for the zip command is as follows:
Where:
- options: Various options that modify the behavior of the zip command.
- zipfile: The name of the zip file to be created or modified.
- files: A list of files or directories to be added to the zip file.
zip Command Options:
- -r: Recursively zip the specified directories and their contents.
- -u: Update the specified zipfile with newer files.
- -d: Delete files from the zipfile.
- -e: Encrypt the zipfile using a password.
Example Usages
-
Create a new zipfile containing a single file.:
Output:
Explanation: The zip command creates a new zipfile called 'example.zip' containing the file 'example.txt'.
-
Create a new zipfile containing multiple files.:
Output:
Explanation: The zip command creates a new zipfile called 'archive.zip' containing the files 'file1.txt', 'file2.txt', and 'file3.txt'.
How Scaler Transformed Careers in Different Fields
Scaler learners achieved 2.5x salary growth with average post-Scaler CTC reaching ₹23L.
Tips
-
Use the '-j' option to store files without directory structure.
-
To view the contents of a zipfile without extracting, use the 'unzip -l' command.
Advanced Use Cases of zip Command in Linux
-
Create a password-protected zipfile.:
Output:
Explanation: The zip command creates an encrypted zipfile called 'secure.zip' containing the file 'confidential.txt'. The user is prompted to enter and verify a password for encryption.
-
Update an existing zipfile with new or modified files.:
Output:
Explanation: The zip command updates the existing zipfile 'archive.zip' by adding or replacing 'updated_file.txt' with the latest version.
-
Delete a file from a zipfile.:
Output:
Explanation: The zip command removes the file 'unwanted_file.txt' from the existing zipfile 'archive.zip'.
Turn Learning into Career Growth
Conclusion
-
The zip command is a versatile utility for creating, updating, and extracting compressed files and directories.
-
Various options can be used to modify the behavior of the command, such as encryption, updating, and deletion.
-
The zip command can be used in combination with other Linux utilities for efficient file management.