- How to Zip and Unzip Files in Ubuntu 22.04 LTS Linux
- Steps to install and use Zip or Unzip in Ubuntu 22.04
- 1. Update Ubuntu 22.04
- 2. Install ZIP & Unzip on Ubuntu 22.04 Linux
- 2. Zip Linux Command Syntax
- 3. How to Zip a file or folder in Ubuntu 22.04
- 4. Removes/Delete folders and/or files from the Zip archive
- 5. Display the contents of the zip file on Ubuntu
- 6. Password-protected Linux ZIP file
- 7. Unzip a file or folder on Ubuntu 22.04
- 8. Uninstall Zip & Unzip from Ubuntu 22.04
- Leave a Comment Cancel reply
- How to Install Zip and Unzip in Linux
- How to Install Zip/Unzip in Debian/Ubuntu/Mint
- How to Install Zip/Unzip in RedHa/CentOS/Fedora
- How to Install Zip/Unzip in Arch/Manjaro Linux
- How to Install Zip/Unzip in OpenSUSE
- How To Install Zip and Unzip in Linux
- Install Zip/Unzip in Linux
- Leave a Comment Cancel reply
- VS Code Tutorials
How to Zip and Unzip Files in Ubuntu 22.04 LTS Linux
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 archive.zip 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 archive-filename.zip file1 file2 (. )
With this command, an archive “archive-filename.zip” with the files “file1” and “file2” is created or updated in the current directory.
To add a folder to an archive:
zip -r archive-filename.zip folder1 folder2 (. )
This command creates an archive “archive-filename.zip” 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 archive-filename.zip file1 file2
4. Removes/Delete folders and/or files from the Zip archive
zip -d archive.zip file1 file2 folder / * (. )
The command removes the files “file1” and “file2” as well as the folder “folder” & its contents from the archive “archive.zip”
Show more options:
Displays complete help with all available options.
5. Display the contents of the zip file on Ubuntu
This command shows the complete content of the archive “archive.zip”
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 archive.zip 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 archiv.zip -d /tmp/target
Extract the complete archive to “/tmp/target”
Extract only certain files or folders:
unzip archive.zip file1 folder1 file2 -d /tmp/target
-d stands for the directory.
Show more options:
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:
Leave a Comment Cancel reply
This site uses Akismet to reduce spam. Learn how your comment data is processed.
How to Install Zip and Unzip in Linux
Zip is a command-line utility tool used for compressing files and folders. Compression of files & folders enables faster and more efficient transfer, storage, and emailing of files and folders. On the other hand, unzip is a utility tool that helps you decompress files and folders.
Benefits of zipping files:
- Compressed/zipped files take up less disk space, leaving you with more space to work with.
- Zipped files are easy to transfer including uploading, downloading, and attaching them on email.
- You can easily decompress zipped files on Linux, Windows, and even mac.
In this topic, we focus on how you can install the zip and unzip utilities on various Linux distributions.
On this page:
Let’s now see how you can install these useful command-line utilities.
How to Install Zip/Unzip in Debian/Ubuntu/Mint
For Debian-based distributions, install the zip utility by running the command.
After installation, you can confirm the version of zip installed using the command.
For the unzip utility, execute a similar command as shown.
Again, just like zip, you can confirm the version of the unzip utility installed by running.
How to Install Zip/Unzip in RedHa/CentOS/Fedora
Just like on Debian distributions, installing zip and unzip utilities on Redhat distros is quite simple.
To install zip, simply execute:
For the unzip utility, install it by running:
How to Install Zip/Unzip in Arch/Manjaro Linux
For Arch-based distros, run:
How to Install Zip/Unzip in OpenSUSE
On OpenSUSE, run the command below to install zip.
And to install unzip, execute.
$ sudo zypper install unzip
For more information, read our article that shows how to create and extract a zip files in Linux.
Conclusion
For newer versions of Linux distros such as Ubuntu 20.04 and CentOS 8, the zip and unzip utilities already come pre-installed and you are good to go.
We covered how to install zip and unzip command-line tools on various Linux distributions and the benefits that come with compressing files.
How To Install Zip and Unzip in Linux
In this tutorial, we will show you how to install Zip and Unzip on a Linux system.
Zip is a command-line utility tool used to compress files in Linux. File and folder compression allows for quicker and more reliable file and folder transfer, storage, and email. On the other hand, unzip is a utility tool that helps you decompress files and folders.
The zip format is hugely popular because it can:
- Compressed/zipped files so that they eat up less disk space.
- Zipped files are small enough to conveniently transfer over the internet, including uploading, downloading, and attaching them on email.
- Compress and decompress programs that supports zip format are available on major platforms such as Linux, Windows and macOS.
This article assumes you have at least basic knowledge of Linux, i.e. know how to use the shell. The installation is quite simple, demonstrated using a Linux user with root privileges, so that they can add ‘ sudo ‘ to the commands to get root privileges. We will show you through the step-by-step installation of the Zip and Unzip packages on Linux.
By default, zip and unzip are not installed in most Linux systems due to licensing restrictions. In this article, we’ll show you how to install zip and unzip in major Linux distributions.
Also check out: How to install HandBrake, Newman, Cisco Webex, vim in Ubuntu and Debian.
Install Zip/Unzip in Linux
Step 1. Update the system
Before doing anything else, the very first step you need to do is ensure that your system are up-to-date by running the following commands in the terminal.
For Ubuntu/Debian-based distro (Linux Mint, Pop! OS)
sudo pacman -S zip sudo pacman -S unzip
Step 2. Installing zip/unzip using package managers.
Debian-based distributions use apt as their default package manager. So if you’re running either Debian, Ubuntu or Linux Mint, run the following commands to install the zip utility:
sudo apt install zip sudo apt install unzip
Sit back and wait a minute, until the installation is finished. The first line installs the zip package while the latter fetches the unzip utility for decompression. Once the installation completes, you can confirm the version number of zip using the command below.
For CentOS/Fedora system, install the zip with dnf package manager by running the command:
sudo dnf install zip sudo dnf install unzip
For Arch-based distros which use pacman package manager, run the following command to install zip and unzip:
sudo pacman -S zip sudo pacman -S unzip
The syntax for zipping a folder includes -r flag, which stands for recursive:
zip -r compressed_filename.zip folder_name
Code language: CSS (css)
The syntax for unzipping a file is even simpler, just run unzip followed by the filename to decompress it.
unzip compressed_filename.zip
Code language: CSS (css)
We hope that the information above helped you successfully install zip and unzip on your Linux system. We’ve also covered other software installation for Linux, especifically Debian and Ubuntu, such as how to install Discord and Chromium in case you’re interested.
If you have any suggestion, please feel free to leave a comment below.
Leave a Comment Cancel reply
Hey! I’m Daan. I work as a SysAdmin in the Netherlands. Whenever I find free time, I write about IT, Linux, Open Source and hardware on this site.
VS Code Tutorials
- Automatic code indentation
- Comment out multiple lines
- Quickly duplicate a line in VSCode
- Create a comment block in VSCode
- Show hidden files in VSCode
- Quickly find a file in VSCode
- How to delete the whole line in VSCode
- Collapse code blocks in VSCode
- Enable/disable word wrap in VSCode
- Bind terminal commands to VSCode keyboard shortcuts
- VSCode Command Palette
- VSCode Format On Save
- VSCode «go to definition» guide