• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • VCS
  • Interview Questions
  • Database
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

How to install zip/unzip package in Linux CentOS/RHEL 7 and 8

by admin

Most PC users, whether familiar with Unix or not, know about Zip files. The zip command offers compression that is based on the algorithm from the PC standard PKZip program. The zip and unzip programs work exactly as you might expect them to: zip [filename] to compress a file with zip, and unzip [filename.z] to unzip the files.

Syntax:

# zip [options] zipfile [files]

Example:
To create a compressed file named mail.zip that contains all the files in the /etc/mail directory, use the following format:

$ zip mail /etc/mail*
  adding: etc/mail/ (stored 0%)
  adding: etc/mailcap (deflated 53%)
  adding: etc/mailman/ (stored 0%)
  adding: etc/mail.rc (deflated 49%)

The following table details some important options:

Option Description
-d Decompress the file (you can also use the unzip command). Note that the zipped file is not deleted.
-v Verbose: Display percentage of compression.
-u Update a .zip file with new content.
-r Zips recursively, meaning you can specify a directory, and all of the contents in that directory (including all subdirectories and their contents) will be zipped.
-x file(s) Specify file(s) to be excluded from the .zip file.

Check if zip/unzip is already Installed

Run the following command to check zip and unzip utility is installed or not:

# rpm -q zip unzip
package zip is not installed
package unzip is not installed
#

Install zip/unzip

If you find it is not installed in system then install with following command:

# yum install zip unzip
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
.......
Installed:
  unzip.x86_64 0:6.0-16.el7                                                     
  zip.x86_64 0:3.0-11.el7

Complete!
#

Verify Installation

Use the following commands to verify the installation:

# rpm -q zip unzip
zip-3.0-11.el7.x86_64
unzip-6.0-16.el7.x86_64
# which zip unzip
/bin/zip
/bin/unzip
#

Zip/unzip is installed on the system and zip command is available to zip a directory!!!

Filed Under: Linux

Some more articles you might also be interested in …

  1. ldd: command not found
  2. gh completion: Generate shell completion scripts for GitHub CLI commands
  3. mdbook Command Examples in Linux
  4. perf: command not found
  5. pmap Command Examples in Linux
  6. distccd: Server daemon for the distcc distributed compiler
  7. flatpak Command Examples in Linux
  8. factor: Prints the prime factorization of a number
  9. trust Command Examples in Linux
  10. runcon Command Examples in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • Vanilla OS 2 Released: A New Era for Linux Enthusiasts
  • mk Command Examples
  • mixxx Command Examples
  • mix Command Examples

© 2025 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright