zip Command in Linux

Learn via video courses
Topics Covered

Transform Your Career

Choose from our industry-leading programs designed for career success

NSDC Certified

Modern Software and AI Engineering Program

Master full-stack development with AI integration

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Modern Data Science and ML with specialisation in AI

Advanced data science techniques with AI specialization

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Advanced AIML with Specialisation in Agentic AI

Deep dive into AIML with focus on Agentic systems

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

DevOps, Cloud & AI Platform Engineering

Build and manage AI-powered cloud infrastructure

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

AI Engineering Advanced Certification by IIT-Roorkee

Premier AI engineering certification from IIT-Roorkee

3 MonthsDuration
AI-LedCurriculum
Career SupportSupport
Program highlights
Go to Program

Overview

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.
Free Courses by top Scaler instructors
Python Course for Beginners With Certification: Mastering the Essentials
Java Course - Mastering the Fundamentals
DBMS Course - Master the Fundamentals and Advanced Concepts
JavaScript Course With Certification: Unlocking the Power of JavaScript
C++ Course: Learn the Essentials
Python and SQL for Data Science Course
Python Course for Beginners With Certification: Mastering the Essentials
Java Course - Mastering the Fundamentals
DBMS Course - Master the Fundamentals and Advanced Concepts
JavaScript Course With Certification: Unlocking the Power of JavaScript
C++ Course: Learn the Essentials
Python and SQL for Data Science Course

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'.

Scaler Placement Report and Statistics

₹23L
AVG CTC
SCALER PLACEMENT PROOF

Scaler learners achieved 2.5x salary growth with average post-Scaler CTC reaching ₹23L.

11,000+placements
650+companies
Verified data
Hiring Partners:
GoogleGoogleAmazonAmazonMicrosoftMicrosoftFlipkartFlipkartAdobeAdobe1200+ more

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

1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary
1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary

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.