How to Zip & Unzip Files in Ubuntu 22.04 Linux Terminal

How to Zip & Unzip Files in Ubuntu 22.04 Linux Terminal

If you want to compress/zip and extract/unzip any files and directories in ubuntu Linux. So zip and unzip packages should be installed in your ubuntu Linux machine.

So, In this tutorial, you will learn how to compress/zip and extract/unzip files and directories with password protected in linux ubuntu using a terminal or command line.

How to Zip & Unzip Files in Ubuntu 22.04 Linux Terminal

Methods to zip/compress and unzip/extract files and directories with password protected in ubuntu / Linux using the command line or terminal:

  • Method 1: Zip/Compress Files And Directories Ubuntu Terminal
  • Method 2: Extract/Unzip Files And Directories Ubuntu Terminal

Method 1: Zip/Compress Files And Directories Ubuntu Terminal

zip is not installed by default in most Linux distributions. So, you can easily install it using the following command.

Now open your terminal and execute the following command on it to install zip package:

  • To install zip on Ubuntu and Debian:
sudo apt install zip
  • To install zip on CentOS and Fedora:
sudo yum install zip
  • To ZIP Files and Directories

To zip one file. So, you can easily zip it by using the following command:

zip filename

To zip one directory. So, you can easily zip it by using the following command:

zip directory_name
  • To ZIP Multiple Files and Directories

To zip multiple file. So, you can easily zip it by using the following command:

zip archivename.zip filename1 filename2 filename3

To zip multiple directory. So, you can easily zip it by using the following command:

zip -r archivename.zip directory_name1 directory_name2 file1 file1
  • Creating a Password Protected ZIP file

To create password procted zip file in linux system. So, you can execute the following command on your terminal:

zip -e  archivename.zip directory_name

The command will be prompted to enter and verify the archive password:

Enter password:
Verify password:

Method 2: Extract/Unzip Files And Directories Ubuntu Terminal

unzip is not installed by default in most Linux distributions. So, you can easily install it using the following command.

Now open your terminal and execute the following command on it to install zip package:

  • To install unzip on Ubuntu and Debian:
sudo apt install unzip
  • To install unzip on CentOS and Fedora:
sudo yum install unzip
  • To unzip Files and Directories

To unzip one file. So, you can easily unzip it by using the following command:

unzip filename

To unzip one directory. So, you can easily unzip it by using the following command:

unzip directory_name
  • To unzip Multiple Files and Directories

To zip multiple file. So, you can easily unzip it by using the following command:

unzip archivename.zip filename1 filename2 filename3

To unzip multiple directory. So, you can easily unzip it by using the following command:

Alternate way to unzip multiple files and directories in linux using command line. You can use regular expressions, as shown below:

unzip '*.zip'
zip -r archivename.zip directory_name1 directory_name2 file1 file1
  • Unzip a ZIP File to a Different Directory

To unzip file or directories in diffrent direcoties, so you can use the following command:

unzip filename.zip -d /path/to/directory
  • Unzip a Password Protected ZIP file or Directories

To unzip password procted file or directories in linux using command line, so you can use the following command:

unzip -P PasswOrd filename.zip
unzip filename.zip -d /path/to/directory

Conclusion

how to zip and unzip files and directories in ubuntu / Linux using the terminal. In this tutorial, you have learned how to create a zip file in Linux using terminal and how to extract or unzip files and directories using the terminal in Linux.

Recommended Posts

AuthorAdmin

My name is Devendra Dode. I am a full-stack developer, entrepreneur, and owner of Tutsmake.com. I like writing tutorials and tips that can help other developers. I share tutorials of PHP, Python, Javascript, JQuery, Laravel, Livewire, Codeigniter, Node JS, Express JS, Vue JS, Angular JS, React Js, MySQL, MongoDB, REST APIs, Windows, Xampp, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL and Bootstrap from a starting stage. As well as demo example.

One reply to How to Zip & Unzip Files in Ubuntu 22.04 Linux Terminal

  1. Thank you, I’m a novice in Linux, it was really helpful!

Leave a Reply

Your email address will not be published. Required fields are marked *