How to Unzip Files in Linux

How to Unzip Files in Linux (with Examples)

This article will explain how to use the unzip command in Linux to list, test, and extract compressed ZIP archives.

Transferring data between computers and servers is made simple and efficient by zipping files.

When files are compressed, they save disk space on a local drive and make it easier and more convenient to download files from the internet, using far less bandwidth than sending full-size files in most cases.

So you’ve been sent a zip file, and now you’re stuck figuring out how to unzip it’s content on Linux? You can use the unzip command to extract (unzip) the file on Linux.

First, you must install unzip because it is not installed by default in most Linux distributions.

Install unzip command on Fedora / Redhat / AlmaLinux / Rocky Linux

sudo dnf install unzip

Install unzip command on Ubuntu / Debian / Linux Mint

sudo apt install unzip

How to Unzip a ZIP File in Linux

Using unzip command in Linux is absolutely simple. You need to tell unzip the name of the zip file which you want to unzip.

unzip <archivename>

For example, in the directory, where you have a zip file named my-archive.zip, to unzip it, the command would be:

unzip my-archive.zip
How to Unzip a ZIP File in Linux

Just like zip, unzip has a -q (quiet) option so that you do not need to see the file listing as the files are extracted.

unzip -q my-archive.zip

Unzip File in Linux to a Directory

In addition, a good practice is to unzip to a directory in the Linux command line. This way, all the extracted files are stored in the directory you specified.

If the directory doesn’t exist, it will create one.

unzip my-archive.zip -d my_files/
Unzip File in Linux to a Directory

How to List the Content of a ZIP file

You can list the content of the zip file without even extracting it with the -l option.

unzip -l my-archive.zip
List the Content of a ZIP file

Testing a ZIP Archive’s Integrity

Sometimes you may want to test a zip archive without extracting it. To test the validity of the zip file, pass option -t as shown below.

unzip -t my-archive.zip
Testing a ZIP Archive’s Integrity

This option extracts each specified file in memory and compares the CRC (Cyclic Redundancy Check, an enhanced checksum) of the expanded file with the original’s stored CRC value.

Conclusion

Now you know how to unzip files in Linux. For detailed information, you can head to the command’s man page.

In addition, our excellent guide, “How to Extract tar.gz File in Linux by Using the Command Line,” will show you how to extract and work with the other widely popular Linux archive format, .tar.gz.

Feel free to leave a comment if you have any questions.

Bobby Borisov
Bobby Borisov

Bobby is a Linux professional with over 20 years of experience. With a strong focus on Linux and open-source software, Bobby has worked as a Linux System Administrator, Software Developer, and DevOps Engineer for small and large multinational companies.

Leave a Reply

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