LinuxTutorials

How To Install Zip and Unzip on Linux

Install Zip and Unzip on Linux

Zip and unzip are essential utilities for file compression and decompression in Linux. These tools allow users to efficiently compress files and directories, saving storage space and making it easier to transfer data across networks. In this comprehensive guide, we will walk you through the process of installing zip and unzip on various Linux distributions, provide step-by-step instructions for basic and advanced usage, and offer troubleshooting tips to help you overcome common issues.

Understanding Zip and Unzip

Zip is a widely used file format for compressing and archiving files. It allows you to package multiple files and directories into a single, compressed file with a .zip extension. Unzip, on the other hand, is a command-line tool used to extract files from a zip archive. These utilities are particularly useful when you need to save disk space, send files over email, or upload them to a website.

Benefits of using Zip and Unzip in Linux

  • Reduced file sizes, making storage and transfer more efficient
  • Ability to package multiple files and directories into a single archive
  • Cross-platform compatibility, as zip files can be opened on various operating systems
  • Option to password-protect sensitive data within zip files

Pre-installation Checks

Before proceeding with the installation of zip and unzip, it’s essential to verify if these utilities are already installed on your Linux system. Open a terminal and run the following commands:

zip --version
unzip --version

If the commands return version information, zip and unzip are already installed, and you can skip the installation steps. However, if you encounter a “command not found” error, you’ll need to install the utilities.

Next, ensure that your system meets the requirements for installing zip and unzip. These utilities have minimal dependencies and should work on most modern Linux distributions. Lastly, make sure you have sudo privileges to install packages on your system

Install Zip and Unzip on Linux

  • For Debian-based distributions, install the zip utility by running the command:
sudo apt install zip
sudo apt install unzip
  • For the CentOS system, install the zip utility by running the command:
sudo dnf install zip
sudo dnf install unzip
  • For Arch Linux-based distributions, install the zip utility by running the command:
sudo pacman -S zip
sudo pacman -S unzip

How to Unzip a ZIP File in Linux.

After installing the zip utility, you can create a zip file using the following command:

zip -r compressed_filename.zip folder_name

Using unzip command in Linux is simple. You need to tell unzip the name of the zip file which you want to unzip.

unzip compressed_filename.zip -d destination_folder

Zip Linux Command Syntax:

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.

# Here are the options that we can use with the ZIP commands-

-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
-h2 show more help

Congratulations! You have successfully installed Zip and Unzip. Thanks for using this tutorial for installing the Zip and Unzip on your Linux system. For detailed information, you can head to the command’s man page.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is a dedicated and highly skilled Linux Systems Administrator with over a decade of progressive experience in designing, deploying, and maintaining enterprise-grade Linux infrastructure. His professional journey began in the telecommunications industry, where early exposure to Unix-based operating systems ignited a deep and enduring passion for open-source technologies and server administration.​ Throughout his career, r00t has demonstrated exceptional proficiency in managing large-scale Linux environments, overseeing more than 300 servers across development, staging, and production platforms while consistently achieving 99.9% system uptime. He holds advanced competencies in Red Hat Enterprise Linux (RHEL), Debian, and Ubuntu distributions, complemented by hands-on expertise in automation tools such as Ansible, Terraform, Bash scripting, and Python.
Back to top button