News
3 new Serverspace GPT API Language Models available now!
JT
July 11 2025
Updated July 11 2025

How to use zip on Linux?

Linux

The zip utility is a simple and convenient way to compress files or directories in the format.zip directly from the Linux command line. It is often used to back up, send data, and merge files.

In this article, you will learn:

  • How to install zip and unzip
  • How to archive and decompress files
  • How to encrypt an archive
  • Typical mistakes and tips

Zip and unzip installation

If the utility is not installed, install it using the command depending on your system.:

# Ubuntu / Debian
sudo apt update
sudo apt install zip unzip

# CentOS / RHEL
sudo yum install zip unzip

# Arch Linux
sudo pacman -S zip unzip

Creating an archive

Archiving a single file:

zip archive.zip myfile.txt

Folder archiving recursively:

zip -r archive.zip myfolder/

Archiving multiple files and folders:

zip -r backup.zip folder1/ file2.txt notes.doc

Unpacking the archive

unzip archive.zip

Unpacking to the specified directory:

unzip archive.zip -d /path/to/folder/

Unpacking a single file:

unzip archive.zip file.txt

Additional options

Key Purpose
-r Recursively adding directories
-e Password encryption of the archive
-9 Maximum compression level
-x Exclusion of files by mask
-q Quiet mode

Creating a secure archive

zip -re secure.zip secret-folder/

After launching, you will be prompted to enter and confirm your password.

Working with files in an archive

Add a file to the archive:

zip archive.zip newfile.txt

To delete a file from the archive:

zip -d archive.zip oldfile.txt

Common errors

Error The reason The solution
command not found: zip The utility is not installed Install the zip through the package manager
filename not matched File not found Check the name and path
bad password Incorrect password Check the password or recreate the archive

Useful tips

  • Avoid spaces in paths, or use quotation marks:
    zip "archive name.zip" "My Folder/"
  • Add the date to the archives:
    zip -r backup_$(date +%Y-%m-%d).zip data/

The zip and unzip utilities are a reliable tool for compressing files on Linux. They are easy to use, do not require a GUI, and are ideal for automating archiving via scripts or cron.

Vote:
5 out of 5
Аverage rating : 5
Rated by: 1
33145 North Miami, FL 2520 Coral Way apt 2-135
+1 302 425-97-76
700 300
ITGLOBAL.COM CORP
700 300

You might also like...

We use cookies to make your experience on the Serverspace better. By continuing to browse our website, you agree to our
Use of Cookies and Privacy Policy.