How to Unzip Files in Linux and Ubuntu

Zip files are compressed folders that contain different files and directories. The Files are usually compressed for better organization and transmission and to prevent compromising data integrity and security.

Linux and Ubuntu allow users to zip and unzip files and directories. However, unlike other operating systems, both have a slightly different way of doing things. This tutorial will explore How to unzip files on Linux and Ubuntu and how to use zip files in different scenarios.

How to Unzip File in Ubuntu/Linux using the Command Line

Use the following steps to unzip a zip file in Linux:

Step 1) Open your terminal.

Unzip File in Ubuntu/Linux using the Command Line

Locate the terminal on your computer and double-click on it.

Step 2) Navigate to the directory. You can do this by typing the CD command followed by the directory path to access the file in its folder.

cd Documents

Unzip File in Ubuntu/Linux using the Command Line

In this case, the file is located in the Documents folder.

Step 3) Use the Linux unzip command.


Unzip File in Ubuntu/Linux using the Command Line

The file, in this scenario, is called Remember to replace <> with the actual name of your zipped file.

Step 4) Extract the file to your preferred location. For example:

unzip -d <destination>

Unzip File in Ubuntu/Linux using the Command Line

The unzip Linux command extracts the contents of a zip file in its current directory. You can pick a preferred location using the -d command.

Replace <destination> with the name of your preferred folder.

Step 5) Verify the extracted files using the ls command. Type ls on your terminal to see the list of the files on your system and verify that the files have been successfully unzipped once done.

Unzip File in Ubuntu/Linux using the Command Line

The unzip command has other different components that make it easier to unzip zip files in Linux such as:

  • [options]: This refers to the different options you can use with the unzip command. Some of the most common options include:
    • -l: List the contents of the zip file without extracting them.
    • -v: Display verbose output while extracting files.
    • -q: Perform the extraction quietly without showing any output.
    • -o: Overwrite existing files without prompting for confirmation.
  • <zipfile>: Specifies the name or path of the extracted zip file.
  • [-d <destination>]: This is usually optional, allowing you to specify the destination directory where you want to place the extracted files. This is usually optional allowing you to direct Linux unzip to the directory of your choice.

You can always type the command on your terminal for more information on its usage and available options.

Note: Linux commands are case-sensitive. Therefore, always use proper capitalization when specifying the file and directory names.

You can refer to the command’s manual page by running man unzip in the terminal to learn more about using the unzip command.

How to Unzip Files in Linux using a GUI Tool

You will need a Linux distribution, such as Ubuntu, to use the GUI tool. Ubuntu provides users with a user-friendly archive manager tool for working with zipped files. This makes it possible to use Ubuntu to unzip files.

How to unzip files using Ubuntu’s archive manager

To unzip files on Ubuntu using the archive manager:

Step 1) Locate the zip file on your computer.

Unzip Files in Linux using a GUI Tool

Step 2) Right-click on your archive file to reveal a context menu.

Unzip Files in Linux using a GUI Tool

Step 3) Select the preferred destination for your extracted files by picking either “Extract Here” or “Extract to…”.

Unzip Files in Linux using a GUI Tool

Step 4) Pick your preferred destination for your extracted files if you choose “Extract to… “.

Unzip Files in Linux using a GUI Tool

Step 5) Click “Select” to proceed and wait for the extraction.

Unzip Files in Linux using a GUI Tool

Step 6) Access the extracted files in the specified destination directory. Your extracted files will retain the names and locations of the original zip file.

Unzip Files in Linux using a GUI Tool

The archive manager provides a user-friendly interface to create, view, and extract various zip formats. It allows you to compress, extract and manage files within the archives more easily than when working with the terminal.

Common Problems when Unzipping Files on Linux

It is also possible to encounter issues when unzipping files on Linux. Some of these problems include

Insufficient File Permissions

Lack of the necessary permissions to access a zip file can cause errors during unzipping. For example, opening a password-protected zip file without the right password will cause issues. To avoid such issues, you must have the required permissions when accessing zip files.

File Corruption

Corrupted files will also be problematic during the unzipping process. Usually, corruption happens during the download process. Other times, it happens due to other factors, such as poor file handling in storage.

If you encounter an issue during unzipping due to corruption, try downloading the zip file again or getting another version of the zip file that is not corrupted.

Incompatible Compression Formats

Zip files come in various compression formats. It is important to note these formats because each format has a corresponding unzip command. Trying to unzip a TAR file using the ‘unzip’ command for a ZIP file will cause issues.

Incomplete Downloads

Incomplete downloads can also cause issues when unzipping files. Make sure you have downloaded the complete file before unzipping the file.

Lack of Required Tools

Some formats will encounter issues if you lack the tools to unzip them. For example, you will have issues when trying to unzip and extract a RAR file if you haven’t installed the ‘rar’ utility on Linux.

Filename Encoding Issues

You might also have issues if you try to unzip a file whose filenames use a different character encoding than the one set on your system. Therefore, ensure that the character encoding on your system matches the filenames in the zip file.

File Size Limitations

You might encounter problems unzipping files of certain sizes if there are limitations on the file sizes on your system. This leads to errors every time you try to extract large files. Make sure to check your file system limitations and adjust accordingly when needed.

Advanced Zip File Techniques

It is also possible to perform advanced actions on zip files in the command line interface in Linux.

Some of the advanced actions to create and modify different files include:

Step 1) Add files to an existing zip file:

zip -u file3.txt

The -u option allows you to update an existing zip file i.e., with file3.txt.

Step 2) Delete files from a zip file:

zip -d file2.txt

The -d option allows you to delete file2.txt from the archive.

Step 3) List a zip file’s contents:

unzip -l

The -l option with the unzip command allows you to list the content of the archive without extracting them.

Step 4) Password-protect zip files

You can protect your zip files using a password by using the -p option followed by your desired password.

zip -r -e -P <password> <archive_name>.zip <file1> <file2> <file3> ...

Replace <password> with your desired password, <archive_name>.zip with the desired name for your zip file, and <file1>, <file2>, <file3> … with the list of files or directories that you would like to add in your zip archive.

For example, if you want to create a password-protected file names, which will contain file1.txt and directory/, you would run:

zip -r -e -P mypassword file1.txt directory/

Re-enter the password for confirmation. The password will also be required when extracting or viewing contents in the archive.

Step 5) Use zip files for backups

Type the following command on your terminal to use zip files as backups in Linux.

zip -r <file1> <file2> <directory1> <directory2> …

Replace <file1> <file2> <directory1> <directory2> with the files and directories you would like to include in the backup.

Step 6) Update an existing backup zip file

It is possible to update an existing backup zip file with newer versions of files.

To do this, type the following command on the terminal:

zip -ur <file1> <file2> <directory1> <directory2>

The -u option will update the existing backup zip file ( with updated versions of the files and directories. Only unchanged files or those not already in the archive will be added.

For example, to update the backup with a modified version of file1.txt, file2.txt directory1/, and directory2/, run:

zip -ur file1.txt file2.txt directory1 directory2

Step 7) Extract files from a backup zip file to a specific directory

If you wish to work with a Linux zip file and extract it from a backup file and into a working directory:


Step 8) Unzip many files in a folder

To unzip multiple files in a specific folder:

unzip '*.zip'

List the contents of a backup file

Use the following command to list a backup file’s contents without extracting them.

unzip -l


Zipping and unzipping files allow us to organize and transfer files more securely. While Linux and Ubuntu are powerful and versatile operating systems, their zipping and unzipping processes remain easy and efficient, allowing you to easily handle different files and directories.