• 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. alacritty – Cross-platform, GPU-accelerated terminal emulator (Command Examples)
  2. snmpwalk: command not found
  3. debman Command Examples in Linux
  4. dolt clone: Clone a repository into a new directory
  5. /proc/cpuinfo file explained
  6. uvcdynctrl Command Examples in Linux
  7. CentOS / RHEL 6 : How to disable telnet service
  8. locale Command Examples in Linux
  9. Audit rules to log reboot command executions in CentOS/RHEL
  10. How to Setup SSH keys for “passwordless” ssh login in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • “glab issue” Command Examples
  • “glab auth” Command Examples
  • “glab alias” Command Examples
  • gixy Command Examples

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright