How to Install Unzip to Extract Zip File on Linux RHEL, CentOS, Oracle Linux 6/7

Zip and Unzip are essential tools for compressing and decompressing files on Linux systems. They allow you to save disk space, improve transfer speeds, and simplify file management by bundling multiple files into a single archive.

In this short guide, we will walk you through the process of installing Zip and Unzip utilities on various Linux distributions, including Debian-based systems (e.g., Ubuntu), and Red Hat-based systems (e.g., CentOS, Fedora). By following these steps, you will be able to compress and decompress files efficiently on your Linux machine.

Installing Zip and Unzip on Debian-based Systems

Open the terminal on your Debian-based Linux machine (e.g., Ubuntu).
Update the package list by entering the following command:

sudo apt-get update

Install Zip and Unzip utilities with this command:

sudo apt-get install zip unzip

Press Enter and wait for the installation to complete.

Installing Zip and Unzip on Red Hat-based Systems

Open the terminal on your Red Hat-based Linux machine (e.g., CentOS, Fedora).
Update the package list by entering the following command:

sudo yum update

Install Zip and Unzip utilities with this command:

sudo yum install zip unzip

Press Enter and wait for the installation to complete.

You have successfully installed the Zip and Unzip utilities.

# zip
Copyright (c) 1990-2008 Info-ZIP - Type 'zip "-L"' for software license.
Zip 3.0 (July 5th 2008). Usage:
zip [-options] [-b path] [-t mmddyyyy] [-n suffixes] [zipfile list] [-xi list]
  The default action is to add or replace zipfile entries from list, which
  can include the special name - to compress standard input.
  If zipfile and list are omitted, zip compresses stdin to stdout.
  -f   freshen: only changed files  -u   update: only changed or new files
  -d   delete entries in zipfile    -m   move into zipfile (delete OS files)
  -r   recurse into directories     -j   junk (don't record) directory names
  -0   store only                   -l   convert LF to CR LF (-ll CR LF to LF)
  -1   compress faster              -9   compress better
  -q   quiet operation              -v   verbose operation/print version info
  -c   add one-line comments        -z   add zipfile comment
  -@   read names from stdin        -o   make zipfile as old as latest entry
  -x   exclude the following names  -i   include only the following names
  -F   fix zipfile (-FF try harder) -D   do not add directory entries
  -A   adjust self-extracting exe   -J   junk zipfile prefix (unzipsfx)
  -T   test zipfile integrity       -X   eXclude eXtra file attributes
  -y   store symbolic links as the link instead of the referenced file
  -e   encrypt                      -n   don't compress these suffixes
# unzip
UnZip 6.00 of 20 April 2009, by Info-ZIP.  Maintained by C. Spieler.  Send
bug reports using; see README for details.

Usage: unzip [-Z] [-opts[modifiers]] file[.zip] [list] [-x xlist] [-d exdir]
  Default action is to extract files in list, except those in xlist, to exdir;
  file[.zip] may be a wildcard.  -Z => ZipInfo mode ("unzip -Z" for usage).

  -p  extract files to pipe, no messages     -l  list files (short format)
  -f  freshen existing files, create none    -t  test compressed archive data
  -u  update files, create if necessary      -z  display archive comment only
  -v  list verbosely/show version info       -T  timestamp archive to latest
  -x  exclude files that follow (in xlist)   -d  extract files into exdir
  -n  never overwrite existing files         -q  quiet mode (-qq => quieter)
  -o  overwrite files WITHOUT prompting      -a  auto-convert any text files
  -j  junk paths (do not make directories)   -aa treat ALL files as text
  -U  use escapes for all non-ASCII Unicode  -UU ignore any Unicode fields
  -C  match filenames case-insensitively     -L  make (some) names lowercase
  -X  restore UID/GID info                   -V  retain VMS version numbers
  -K  keep setuid/setgid/tacky permissions   -M  pipe through "more" pager
See "unzip -hh" or unzip.txt for more help.  Examples:
  unzip data1 -x joe   => extract all files except joe from zipfile
  unzip -p foo | more  => send contents of via pipe into program more
  unzip -fo foo ReadMe => quietly replace existing ReadMe if archive file newer

Some Zip and Unzip Command Options

Here is a list of 5 most popular options for both Zip and Unzip commands that you can use to customize the compression and extraction processes.

See also  How to See How Many Inodes on Linux Servers?

Zip Command Options

  • -r – Recurse into directories: This option allows you to compress directories and their contents recursively, including all subdirectories and files.
  • -9 – Maximum compression level: This option sets the compression level to maximum, resulting in the smallest possible archive size at the cost of increased processing time.
  • -e – Encrypt archive: This option enables you to create a password-protected Zip archive, requiring users to enter the correct password before extracting its contents.
  • -m – Move files: This option moves the original files into the archive instead of copying them. Once the files are compressed, the original files will be deleted from the source location.
  • -v – Verbose mode: This option provides detailed information about the compression process, including the names of the files being added and the compression ratio achieved.
See also  How to use tmpwatch to Auto Clean Up Files and Logs in Linux

Unzip Command Options

  • -l – List archive contents: This option displays the contents of a Zip archive without extracting the files. It shows file names, sizes, and other relevant information.
  • -d – Extract to a specific directory: This option allows you to specify the destination directory for the extracted files. If the directory does not exist, it will be created.
  • -n – Do not overwrite existing files: This option prevents Unzip from overwriting existing files when extracting an archive. If a file with the same name already exists, Unzip will skip the extraction of that file.
  • -o – Overwrite existing files without prompting: This option enables Unzip to overwrite existing files without asking for confirmation, making the extraction process faster and more streamlined.
  • -P – Password: This option allows you to provide the password required to decrypt and extract an encrypted Zip archive. Replace “PASSWORD” with the actual password: `unzip -P PASSWORD`.
See also  How to Display the Number of Processors (vCPU) on Linux VPS

These popular options offer greater control and flexibility when working with Zip and Unzip commands, making it easier to compress and decompress files according to your specific needs.


Extract Files to a Different Destination:

# unzip -d /data

Compressing Files and Folders in Linux:

# tar -czvf filename.tar.gz /path/directory

Extracting All .gz Files in a Directory in Linux:

# gunzip *.gz

Decompressing Files Using ‘gzip’ Command in Linux:

# gzip -d filename.gz

Decompressing a File Using ‘gunzip’ Command in Linux:

# gunzip filename.gz

Compressing Multiple Files into a Single Archive:

# zip file1.txt file2.txt file3.txt

Adding Files to an Existing Zip Archive:

# zip -u newfile.txt

Extracting a Specific File from a Zip Archive:

# unzip file_to_extract.txt -d /destination_directory

Creating a Tarball Archive with Bzip2 Compression:

# tar -cjvf filename.tar.bz2 /path/directory

Extracting a Tarball Archive with Bzip2 Compression:

# tar -xjvf filename.tar.bz2 -C /destination_directory

Commands Mentioned:

  • sudo – Executes a command with elevated privileges, typically required for system administration tasks.
  • apt-get – A command-line package management utility for Debian-based systems.
  • yum – A command-line package management utility for Red Hat-based systems.
  • update – Updates the package list to ensure the latest available versions are installed.
  • install – Installs the specified package(s) and their dependencies.


By following this guide, you have successfully installed the Zip and Unzip utilities on your Linux system, enabling you to compress and decompress files easily. These tools are essential for managing files, saving disk space, and facilitating file transfers.

With Zip and Unzip installed, you can now create compressed archives of your files and extract them when needed. This knowledge is valuable for anyone working with large files, handling backups, or sharing data across different systems.

Feel free to share your thoughts, comments, and suggestions for improvements to this guide. Your feedback helps us ensure the accuracy and usefulness of our content.



  • Avatar rahulteja says:

    Thank you for the post. Helped me a lot…

  • Avatar jack miller says:

    Thank you for helping people get the information they need. Great stuff as usual. Keep up the great work.

  • Avatar Maria says:

    I’d like to express my gratitude for this well-crafted guide. The examples you’ve provided made it easy to understand and follow the instructions. Thanks for taking the time to create and share this excellent resource!

  • Avatar Jason says:

    Thank you for sharing this valuable information! Your clear explanations and step-by-step instructions have been incredibly helpful. I truly appreciate your efforts in putting together such a comprehensive guide.

Leave a Reply

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