How to Zip and Unzip Files in Ubuntu 22.04 LTS Linux

Learn the commands to install Zip and Unzip in Ubuntu 22.04 LTS Jammy JellyFish to extract the compressed files and folders archived in a ZIP format.

This tutorial will help the users to learn the command to ZIP and unzip in Ubuntu Terminal. Zip is a command Archive format that can be used on almost all operating systems to use, especially on Windows. However, all Linux distros don’t have a tool to extract the Zip format files by default, for example, Ubuntu (especially the minimal installation). In such as case we manually have to install a command line tool to extract our files.

Steps to install and use Zip or Unzip in Ubuntu 22.04

1. Update Ubuntu 22.04

The Archive manager we are about to install is available through the default system repository and APT package manager. Therefore, before going further, let’s first run the system update command:

sudo apt update && sudo apt upgrade -y

2. Install ZIP & Unzip on Ubuntu 22.04 Linux

To create or unpack Zip archives under Ubuntu 22.04 Linux, you must first ensure that the required tool is available on the system. Although, generally ZIP and unzip tools come pre-installed however, if not then use the below-given command:

sudo apt install zip unzip

2. Zip Linux Command Syntax

Next, we should know what are options available to use with ZIP or Unzip Commands. Here is the List of the common ones along with their usage 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

Let’s see some common commands that will help us to use this tool for extracting archive files and repacking the ones we want.

3. How to Zip a file or folder in Ubuntu 22.04

The syntax of the ZIP commands will always be the same even for Ubuntu and other Linux distros.

zip options files and folders list

If the archive already exists, the files and folders are added to the archive or updated. The archive is not going to be replaced.

Add individual files to an archive:

zip file1 file2 (...)

With this command, an archive “” with the files “file1” and “file2” is created or updated in the current directory.

To add a folder to an archive:

zip -r folder1 folder2 (...)

This command creates an archive “” with the folders “folder1” and “folder2” including all subfolders and files in the current directory.

Create a Zip archive and delete the original files

With creating of Archive file you want to remove the original files or folders that have been used to create the ZIP archive file of yours, then use -m option. It is meant to move files permanently rather than copying them to the archive.


zip -m file1 file2

4. Removes/Delete folders and/or files from the Zip archive 

zip -d file1 file2 folder / * (...)

The command removes the files “file1” and “file2” as well as the folder “folder” & its contents from the archive “”

Show more options:

zip -h2

Displays complete help with all available options.

5. Display the contents of the zip file on Ubuntu 

unzip -l

This command shows the complete content of the archive “”

6. Password-protected Linux ZIP file

Many times, we need protection for sensitive files or data while archiving them. Thus, if you want to create a Linux zip with a password then simply use -e option. With this, we can significantly improve the security of our zipped files.

zip -e file1 file2

As you use -e parameter, the system will ask you to create a password for the files by entering it two times.

7. Unzip a file or folder on Ubuntu 22.04

Once you have learned the way to put your files and folder in a ZIP format archive on Ubuntu. Let’s see the way to extract the content of an existing ZIP file.

Unpack the complete archive:


Unpacks the complete archive into the current directory.

Extract the archive to a specific location:

unzip -d /tmp/target

Extract the complete archive to “/tmp/target”

Extract only certain files or folders:

unzip file1 folder1 file2 -d /tmp/target

-d stands for the directory.

Show more options:

unzip -hh

Displays complete help with all available options.

unzipsfx options:
-c, -p - Output to pipe. (See above for unzip.)
-f, -u - Freshen and Update, as for unzip.
-t - Test embedded archive. (Can be used to list contents.)
-z - Print archive comment. (See unzip above.)

unzipsfx modifiers:
Most unzip modifiers are supported. These include
-a - Convert text files.
-n - Never overwrite.
-o - Overwrite without prompting.
-q - Quiet operation.
-C - Match names case-insensitively.
-j - Junk paths.
-V - Keep version numbers.
-s - Convert spaces to underscores.
-$ - Restore volume label.

8. Uninstall Zip & Unzip from Ubuntu 22.04

After some time if you don’t want this Archive manager in your Linux then here is the command to completely remove Zip & Unzip from your Ubuntu 22.04 along with their dependencies.

sudo apt autoremove --purge unzip zip

Ending note:

These were a few common ZIP and Unzip commands that we can use on Ubuntu 22.04 Linux operating system for packaging or unpacking archive files using the terminal.

Other Articles:

How to install p7Zip GUI on Ubuntu 20.04 LTS
How to install GitEye GUI Git client on Ubuntu 22.04 | 20.04 LTS
Install p7Zip GUI on Ubuntu 22.04 LTS Jammy Linux
How to Edit Files as Root in Ubuntu using GUI File Manager

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.