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

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • 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. setenforce Command Examples in Linux
  2. How to Customize Linux Password Expiration and Complexity Requirements
  3. dir Command Examples in Linux
  4. How to change the number of commands stored in Bash History
  5. How to Stop Audit Log Entries Written to System Logs in CentOS/RHEL 6
  6. nft: command not found
  7. How to Capture More Logs in /var/log/dmesg for CentOS/RHEL
  8. How to change the default location (/var/cache/yum) of yum cache
  9. dig: command not found
  10. Understanding How Umask Controls the Initial File / Directory Permissions in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • raw: command not found
  • raw Command Examples in Linux
  • rankmirrors Command Examples in Linux
  • radeontop: command not found

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright