How to Unzip a Zip File in Ubuntu 22.04?


Software and other files from the internet usually come in the form of archives. Data is compressed and stored in the form of archives to conserve storage space and transmission bandwidth. Data compression allows to reduce the file size while retaining all the information. There are many compressed archive file formats like zip, tar, 7z, rar, etc. The zip is the most popular compressed archive file format due to its cross-platform-compatible nature. The compressed archive is unzipped to use it. Archives can be unzipped via the Terminal and Graphical User Interface.

This article will illustrate several methods of unzipping a zipped archive on Ubuntu 22.04 LTS. This article is organized as follows:

  • How to Install Unzip Utility in Ubuntu 22.04?
  • How to Unzip a File in the Current Directory via CLI?
  • How to Unzip a File in a Specific Directory via Terminal?
  • How to Unzip Selected Files via Terminal?
  • How to Unzip All Zipped Directories via Terminal?
  • How to Verify the Validity of a Zip File?
  • How to Overwrite Existing Files While Unzipping via Terminal?
  • How to Avoid Overwriting while Unzipping a Zip File via Terminal?
  • How to Unzip a File via GUI in Ubuntu 22.04?
  • How to Unzip a Password-Protected File via GUI in Ubuntu 22.04?

How to Install Unzip Utility in Ubuntu 22.04?

The unzip utility allows the unzipping of zipped files. The Unzip utility is pre-installed in Ubuntu 22.04. However, if it is not installed, it can be installed by running the following command:


How to Unzip a File in the Current Directory via Terminal?

To unzip a zipped archive “LinuxGenie.zip”, run the following command:


The above output indicates that the LinuxGenie.zip archive is unzipped, which can be verified by listing the contents of /home/linuxuser/Extra:


How to Unzip a File in a Specific Directory via Terminal?

To unzip a zipped archive “LinuxGenie.zip” from the “home/linuxuser/Extra” directory to “home/linuxuser/Directories”, run the following command:

$ unzip LinuxGenie.zip -d /home/linuxuser/Documents

The above output indicates that the LinuxGenie.zip archive is unzipped in the /home/linuxuser/Documents directory.

How to Unzip Selected Files via Terminal?

Selected files can be unzipped via the unzip utility. To unzip all files excluding File02.txt, File05.txt and File08.txt, run the following command:

$ unzip LinuxGenie.zip -x “*File02.txt*” “*File05.txt*” “*File08.txt*”

The above output indicates that all the files of the LinuxGenie.zip archive are unzipped except File02.txt, File05.txt, and File08.txt.

How to Unzip All Zipped Directories via Terminal?

To unzip multiple zipped archives in a directory, run the following command:


Where *.zip refers to all the zip archives in the current directory, i.e., LinuxGenie1.zip, LinuxGenie2.zip, and LinuxGenie3.zip:

The output in the below image indicates that archives LinuxGenie1.zip, LinuxGenie2.zip, and LinuxGenie3.zip are unzipped to LinuxGenie1, LinuxGenie2, and LinuxGenie3 directories.

How to Verify the Validity of a Zip File?

To check if the contents of the zipped archive are error-free, run the following command:


Where “-t” represents the test archive flag. The test archive extracts each file and verifies the files by comparing the CRC (Cyclic Redundancy check) of the extracted file with the CRC of the original file:

The above output indicates that all the files within LinuxGenie.zip are error-free.

How to Overwrite Existing Files While Unzipping via Terminal?

The unzip utility offers a feature to ask for permission to overwrite a file if a file exists. For example, if a zipped archive is already unzipped and if a user attempts to unzip the archive again, the user is prompted for permissions as shown below:


Similarly, the user will be prompted for permissions for all the files in the archive.

How to Avoid Overwriting while Unzipping a Zip File via Terminal?

By default, the unzip utility prompts the users in case the files being unzipped are already present in the directory. The user is asked to overwrite a file or all files. To avoid overwriting while unzipping a zip file, execute the following command:


Where the “-n” flag will prohibit overwriting if the file already exists.

The above output indicates that the unzip command had skipped the extraction of the zipped archive, LinuxGenie.zip without prompting.

How to Unzip a File via GUI in Ubuntu 22.04?

A zipped archive can be conveniently unzipped via GUI. To unzip a zipped archive, “LinuxGenie.zip”, first select the zipped file:

Then, right-click the selected zipped archive and select “Extract Here” from the down-down menu. Alternatively, select the “Extract to” option to unzip the archive to another directory:

Finally, the zipped archive “LinuxGenie.zip” is unzipped to the “LinuxGenie” directory as shown below:

Additionally, multiple compressed archives can be unzipped in a similar way.

How to Unzip a Password-Protected File via GUI in Ubuntu 22.04?

The password-protected zipped archive enables a layer of security enabling only authorized users to unzip and access the contents of the archive. In this section, a password-protected zip archive is unzipped. To verify the contents of the password-protected zipped archive: LinuxGeniePW.zip, double-click the LinuxGenie.zip:

From the image below, it can be verified that the contents of LinuxGenie.zip are password-protected:

To unzip the LinusGeniePW.zip file, first, select the zipped archive and select “Extract Here” from the down-down menu:

The user will be redirected to a “Password Required” pop-up window. Enter the password in the tab and press the Extract button:

Finally, the password-protected zipped archive “LinuxGeniePW.zip” is unzipped a directory “LinuxGeniePW” as seen below:

To verify if the password-protected files are accessible, double-click the “LinuxGeniePW” directory:

From the above image, it can be seen that the “lock” symbol is removed from the files. Thus, ensuring that the files are unlocked.

Conclusion

Compressed zip archives are extracted by the unzip utility by running the “unzip <archive>” command. Additionally, the unzip utility allows unzipping with many options like unzipping in a specific directory, unzipping by avoiding overwriting, unzipping all archives in a directory, unzipping selected files, checking the validity of a zip archive, and unzipping password-protected archives. This article demonstrated the unzipping of zipped archives via CLI and GUI on Ubuntu 22.04 LTS.

Print Friendly, PDF & Email