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>
Code language: HTML, XML (xml)
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
Code language: CSS (css)
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
Code language: CSS (css)
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/
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
Code language: CSS (css)
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
Code language: CSS (css)
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.