{"id":3086,"date":"2012-05-12T15:12:31","date_gmt":"2012-05-12T07:12:31","guid":{"rendered":"https:\/\/webhostinggeeks.com\/howto\/?p=3086"},"modified":"2023-09-18T16:31:21","modified_gmt":"2023-09-18T16:31:21","slug":"how-to-install-unzip-to-extract-zip-file-on-linux-rhel-centos-oracle-linux-67","status":"publish","type":"post","link":"https:\/\/webhostinggeeks.com\/howto\/how-to-install-unzip-to-extract-zip-file-on-linux-rhel-centos-oracle-linux-67\/","title":{"rendered":"How to Install Unzip to Extract Zip File on Linux RHEL, CentOS, Oracle Linux 6\/7"},"content":{"rendered":"<p>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.<\/p>\n<p>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., <a href=\"https:\/\/webhostinggeeks.com\/blog\/what-is-ubuntu-beginners-guide-ubuntu-linux-distro\/\">Ubuntu<\/a>), and Red Hat-based systems (e.g., <a href=\"https:\/\/webhostinggeeks.com\/blog\/what-is-centos-beginners-guide-centos-linux-distro\/\">CentOS<\/a>, Fedora). By following these steps, you will be able to compress and decompress files efficiently on your Linux machine.<\/p>\n<h2>Installing Zip and Unzip on Debian-based Systems<\/h2>\n<p>Open the terminal on your Debian-based Linux machine (e.g., Ubuntu).<br \/>\nUpdate the package list by entering the following command:<\/p>\n<pre>\r\nsudo apt-get update\r\n<\/pre>\n<p>Install Zip and Unzip utilities with this command:<\/p>\n<pre>\r\nsudo apt-get install zip unzip\r\n<\/pre>\n<p>Press Enter and wait for the installation to complete.<\/p>\n<h2>Installing Zip and Unzip on Red Hat-based Systems<\/h2>\n<p>Open the terminal on your Red Hat-based Linux machine (e.g., CentOS, Fedora).<br \/>\nUpdate the package list by entering the following command:<\/p>\n<pre>\r\nsudo yum update\r\n<\/pre>\n<p>Install Zip and Unzip utilities with this command:<\/p>\n<pre>\r\nsudo yum install zip unzip\r\n<\/pre>\n<p>Press Enter and wait for the installation to complete.<\/p>\n<p>You have successfully installed the Zip and Unzip utilities.<\/p>\n<pre># zip\r\nCopyright (c) 1990-2008 Info-ZIP - Type 'zip \"-L\"' for software license.\r\nZip 3.0 (July 5th 2008). Usage:\r\nzip [-options] [-b path] [-t mmddyyyy] [-n suffixes] [zipfile list] [-xi list]\r\n  The default action is to add or replace zipfile entries from list, which\r\n  can include the special name - to compress standard input.\r\n  If zipfile and list are omitted, zip compresses stdin to stdout.\r\n  -f   freshen: only changed files  -u   update: only changed or new files\r\n  -d   delete entries in zipfile    -m   move into zipfile (delete OS files)\r\n  -r   recurse into directories     -j   junk (don't record) directory names\r\n  -0   store only                   -l   convert LF to CR LF (-ll CR LF to LF)\r\n  -1   compress faster              -9   compress better\r\n  -q   quiet operation              -v   verbose operation\/print version info\r\n  -c   add one-line comments        -z   add zipfile comment\r\n  -@   read names from stdin        -o   make zipfile as old as latest entry\r\n  -x   exclude the following names  -i   include only the following names\r\n  -F   fix zipfile (-FF try harder) -D   do not add directory entries\r\n  -A   adjust self-extracting exe   -J   junk zipfile prefix (unzipsfx)\r\n  -T   test zipfile integrity       -X   eXclude eXtra file attributes\r\n  -y   store symbolic links as the link instead of the referenced file\r\n  -e   encrypt                      -n   don't compress these suffixes\r\n<\/pre>\n<pre># unzip\r\nUnZip 6.00 of 20 April 2009, by Info-ZIP.  Maintained by C. Spieler.  Send\r\nbug reports using http:\/\/www.info-zip.org\/zip-bug.html; see README for details.\r\n\r\nUsage: unzip [-Z] [-opts[modifiers]] file[.zip] [list] [-x xlist] [-d exdir]\r\n  Default action is to extract files in list, except those in xlist, to exdir;\r\n  file[.zip] may be a wildcard.  -Z =&gt; ZipInfo mode (\"unzip -Z\" for usage).\r\n\r\n  -p  extract files to pipe, no messages     -l  list files (short format)\r\n  -f  freshen existing files, create none    -t  test compressed archive data\r\n  -u  update files, create if necessary      -z  display archive comment only\r\n  -v  list verbosely\/show version info       -T  timestamp archive to latest\r\n  -x  exclude files that follow (in xlist)   -d  extract files into exdir\r\nmodifiers:\r\n  -n  never overwrite existing files         -q  quiet mode (-qq =&gt; quieter)\r\n  -o  overwrite files WITHOUT prompting      -a  auto-convert any text files\r\n  -j  junk paths (do not make directories)   -aa treat ALL files as text\r\n  -U  use escapes for all non-ASCII Unicode  -UU ignore any Unicode fields\r\n  -C  match filenames case-insensitively     -L  make (some) names lowercase\r\n  -X  restore UID\/GID info                   -V  retain VMS version numbers\r\n  -K  keep setuid\/setgid\/tacky permissions   -M  pipe through \"more\" pager\r\nSee \"unzip -hh\" or unzip.txt for more help.  Examples:\r\n  unzip data1 -x joe   =&gt; extract all files except joe from zipfile data1.zip\r\n  unzip -p foo | more  =&gt; send contents of foo.zip via pipe into program more\r\n  unzip -fo foo ReadMe =&gt; quietly replace existing ReadMe if archive file newer\r\n<\/pre>\n<h2>Some Zip and Unzip Command Options<\/h2>\n<p>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.<\/p>\n<h3>Zip Command Options<\/h3>\n<ul>\n<li><span class=\"fw-bold\">-r<\/span> &#8211; Recurse into directories: This option allows you to compress directories and their contents recursively, including all subdirectories and files.<\/li>\n<li><span class=\"fw-bold\">-9<\/span> &#8211; 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.<\/li>\n<li><span class=\"fw-bold\">-e<\/span> &#8211; Encrypt archive: This option enables you to create a password-protected Zip archive, requiring users to enter the correct password before extracting its contents.<\/li>\n<li><span class=\"fw-bold\">-m<\/span> &#8211; 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.<\/li>\n<li><span class=\"fw-bold\">-v<\/span> &#8211; Verbose mode: This option provides detailed information about the compression process, including the names of the files being added and the compression ratio achieved.<\/li>\n<\/ul>\n<h3>Unzip Command Options<\/h3>\n<ul>\n<li><span class=\"fw-bold\">-l<\/span> &#8211; 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.<\/li>\n<li><span class=\"fw-bold\">-d<\/span> &#8211; 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.<\/li>\n<li><span class=\"fw-bold\">-n<\/span> &#8211; 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.<\/li>\n<li><span class=\"fw-bold\">-o<\/span> &#8211; 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.<\/li>\n<li><span class=\"fw-bold\">-P<\/span> &#8211; Password: This option allows you to provide the password required to decrypt and extract an encrypted Zip archive. Replace &#8220;PASSWORD&#8221; with the actual password: `unzip -P PASSWORD archive.zip`.<\/li>\n<\/ul>\n<p>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.<\/p>\n<h2>Examples<\/h2>\n<h3>Extract Files to a Different Destination:<\/h3>\n<pre># unzip filename.zip -d \/data\r\n<\/pre>\n<h3>Compressing Files and Folders in Linux:<\/h3>\n<pre># tar -czvf filename.tar.gz \/path\/directory\r\n<\/pre>\n<h3>Extracting All .gz Files in a Directory in Linux:<\/h3>\n<pre># gunzip *.gz\r\n<\/pre>\n<h3>Decompressing Files Using &#8216;gzip&#8217; Command in Linux:<\/h3>\n<pre># gzip -d filename.gz\r\n<\/pre>\n<h3>Decompressing a File Using &#8216;gunzip&#8217; Command in Linux:<\/h3>\n<pre># gunzip filename.gz\r\n<\/pre>\n<h3>Compressing Multiple Files into a Single Archive:<\/h3>\n<pre># zip archive.zip file1.txt file2.txt file3.txt\r\n<\/pre>\n<h3>Adding Files to an Existing Zip Archive:<\/h3>\n<pre># zip -u archive.zip newfile.txt\r\n<\/pre>\n<h3>Extracting a Specific File from a Zip Archive:<\/h3>\n<pre># unzip archive.zip file_to_extract.txt -d \/destination_directory\r\n<\/pre>\n<h3>Creating a Tarball Archive with Bzip2 Compression:<\/h3>\n<pre># tar -cjvf filename.tar.bz2 \/path\/directory\r\n<\/pre>\n<h3>Extracting a Tarball Archive with Bzip2 Compression:<\/h3>\n<pre># tar -xjvf filename.tar.bz2 -C \/destination_directory\r\n<\/pre>\n<h2>Commands Mentioned:<\/h2>\n<ul>\n<li><span class=\"fw-bold\">sudo<\/span> &#8211; Executes a command with elevated privileges, typically required for system administration tasks.<\/li>\n<li><span class=\"fw-bold\">apt-get<\/span> &#8211; A command-line package management utility for Debian-based systems.<\/li>\n<li><span class=\"fw-bold\">yum<\/span> &#8211; A command-line package management utility for Red Hat-based systems.<\/li>\n<li><span class=\"fw-bold\">update<\/span> &#8211; Updates the package list to ensure the latest available versions are installed.<\/li>\n<li><span class=\"fw-bold\">install<\/span> &#8211; Installs the specified package(s) and their dependencies.<\/li>\n<\/ul>\n<h2>Conclusion<\/h2>\n<p>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.<\/p>\n<p>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.<\/p>\n<p>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.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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&#8230;<\/p>\n","protected":false},"author":6,"featured_media":6280,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"wds_primary_category":0,"footnotes":""},"categories":[1],"tags":[1244,1536,1869,1955],"class_list":["post-3086","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized","tag-centos","tag-linux","tag-unzip","tag-zip"],"_links":{"self":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts\/3086","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/comments?post=3086"}],"version-history":[{"count":0,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts\/3086\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/media\/6280"}],"wp:attachment":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/media?parent=3086"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/categories?post=3086"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/tags?post=3086"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}