How do you unzip files using RHEL (or CentOS or Fedora Linux)?

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

Goal:  You want to use unzip when you are using Red Hat Enterprise Linux (or CentOS or Fedora Linux).
Background:  The unzip character-based utility is useful for many reasons.  At the command line you can access compressed files that normally occupy little space on the disk.  Transferring .zip files is great for keeping network bandwidth utilization low.

Try this command to see if zip is installed: man zip

Try this command to see if unzip is installed: man unzip

Part 1:  How to Install Unzip
If the command cannot be found, use these commands:

sudo su -
yum install -y unzip

If you cannot install unzip that way (either because you have no Internet connection or rpm package repository server configured on your network), go to this URL:  http://rpmfind.net

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

While rpmfind.net has no RHEL packages, CentOS rpms should work. They definitely work for RHEL 7.2 for unzip.  

Once the .rpm is downloaded, you can use this command: rpm -ivh unzip-6.0-15.el7.x86_64.rpm

(where unzip-6.0-15.el7.x86_64.rpm is the exact name of the rpm package you downloaded)

Part 2: How to Use Unzip

Now that unzip is installed, you can use it with a command like this (assuming you have a file named foobar.zip):

unzip foobar.zip

The above command will decompress the contents while retaining a copy.  The extracted contents will be decompressed in the same directory you run the command in.  The files will not necessarily go to the directory where foobar.zip is (e.g., if you are in /root/ and run unzip /tmp/foobar.zip the extracted files will go into the /root/ directory).

Leave a comment

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