How do you zip files using Red Hat Enterprise Linux (or CentOS or Fedora Linux)?

Goal:  You want to use zip when you are using Red Hat Enterprise Linux (or CentOS or Fedora Linux).
Background:  The zip character-based utility is useful for many reasons.  At the command line you can free up space while retaining files for future usage.  Try this command to see if zip is installed: man zip

Part 1:  How to install zip?
If the command cannot be found, use these commands:

sudo yum install -y zip

If you do not have access to the Internet, and your network has no rpm  configured, get the file from here:

Search for "zip."  To find the exact version of RedHat you are using, issue this command: cat /etc/*-release

While has no RHEL packages, CentOS rpms should work. They definitely work with RHEL 7.2 for zip.  

Once the .rpm is downloaded, you can use this command: sudo rpm -ivh zip-3.0-10.el7.x86_64.rpm

(where zip-3.0-10.el7.x86_64.rpm is the exact name of the rpm package you downloaded)

Part 2:  How to Use Zip
Now that zip is installed, you can use it with a command like this (assuming you have three regular files named pub.txt, pub1.txt, pub2.txt):

zip pub.txt pub1.txt pub2.txt

The above command will create a zip file called  The files will be compressed (that is, the .zip file will be smaller than the sum of the three .txt files).  This can help reduce disk I/O when fetching the file, moving it around, and reduce network congestion with fewer packets over the network when it is in transit.

Leave a comment

Your email address will not be published. Required fields are marked *