<p><a href="https://www.lifewire.com/zip-file-2622675" data-component="link" data-source="inlineLink" data-type="internalLink" data-ordinal="1">Zipping files</a> is an easy, efficient way to transfer them between computers and servers using far less bandwidth than sending full-size files. When you receive a zipped archive in Linux, decompressing it is just as easy. Here are a few ways to use the <code>unzip</code> command in the <a href="https://www.lifewire.com/linux-gui-vs-command-line-2200166" data-component="link" data-source="inlineLink" data-type="internalLink" data-ordinal="2">Linux command line</a>.</p><h3>Decompressing a Single Zip File Into the Current Folder</h3><p>The basic syntax for decompressing a file is:</p><blockquote><code>unzip filename</code></blockquote><p>As an example, say you&#39;ve zipped up <a href="https://www.lifewire.com/best-linux-audio-programs-for-linux-4082408" data-component="link" data-source="inlineLink" data-type="internalLink" data-ordinal="3">an album</a> called &#34;Menace To Sobriety&#34; by the band Ugly Kid Joe as a zip file named &#34;Menace To Sobriety.&#34;</p><p>To unzip this file into the current folder, simply run the following command:</p><blockquote><code>unzip &#34;Menace To Sobriety&#34;</code></blockquote><h3>Decompressing Multiple Files</h3><p>The <a href="https://www.kernel.org/doc/man-pages/" data-component="link" data-source="inlineLink" data-type="externalLink" data-ordinal="4">man command</a> lets you decompress more than one file at a time using the following syntax:</p><blockquote><code>unzip filename1 filename2 filename3</code></blockquote><p>Say you zipped up three files of Alice Cooper albums named &#34;Trash,&#34; &#34;Hey Stoopid,&#34; and &#34;Dragontown&#34; separately. To unzip these files, you might try entering the following:</p><blockquote><code>unzip &#34;Trash.zip&#34; &#34;Dragontown.zip&#34; &#34;Hey Stoopid.zip&#34;</code></blockquote><p>What you then get, however, is this error:</p><blockquote><code>Archive: Trash.zip</code> <code>caution: filename not matched: Dragontown.zip</code></blockquote><p>Assuming the three files live in the same folder, a better way is to use the following command instead:</p><blockquote><code>unzip &#39;*.zip&#39;</code></blockquote><p>Be careful, though: This command is indiscriminate and will decompress every zip file in the current folder.</p><h3>Unzip a File but Exclude Certain Others</h3><p>If you have a zip file and you want to extract all the files except for one, use the <code>-x</code> switch, as follows:</p><blockquote><code>unzip filename.zip -x filetoexclude.zip</code></blockquote><p>To continue with our example, the album &#34;Trash&#34; by Alice Cooper has a song titled &#34;Bed Of Nails.&#34; To extract all the songs except for &#34;Bed Of Nails,&#34; you&#39;d use the following syntax:</p><blockquote><code>unzip Trash.zip -x &#34;Bed Of Nails.mp3&#34;</code></blockquote><h3>Extract a Zip File to a Different Directory</h3><p>If you want to put the contents of the zip file in a different directory than the current one, use the <code>-d</code> switch, like this:</p><blockquote><code>unzip filename.zip -d path/to/extract/to</code></blockquote><p>For example, to decompress the &#34;Trash.zip&#34; file to &#34;/home/music/Alice Cooper/Trash,&#34; you&#39;d use the following syntax:</p><blockquote><code>unzip Trash.zip -d /home/music/Alice Cooper/Trash</code></blockquote><h3>How to Show the Contents of a Compressed Zip File</h3><p>To list the contents of a compressed file, use the <code>-l</code> switch:</p><blockquote><code>unzip -l filename.zip</code></blockquote><p>To see all the songs in the album &#34;Trash.zip,&#34; use the following:</p><blockquote><code>unzip -l Trash.zip</code></blockquote><p>The information returned includes:</p><ul><li>Length in <a href="https://www.lifewire.com/the-difference-between-bits-and-bytes-816248" data-component="link" data-source="inlineLink" data-type="internalLink" data-ordinal="5">bytes</a></li><li>Date created</li><li>Time created</li><li>Name</li></ul><h3>How to Test If a Zip File Is Valid</h3><p>To test whether a zip file is OK before extracting it, use the <code>-t</code> switch:</p><blockquote><code>unzip -t filename.zip</code></blockquote><p>For example, to test whether &#34;Trash.zip&#34; is valid, you could run the following:</p><blockquote><code>unzip -t Trash.zip</code></blockquote><p>Each file will be listed, and &#34;OK&#34; should appear next to it. At the bottom of the output, a message should appear stating &#34;no errors detected in compressed data of... &#34;</p><h3>Show Detailed Information About a Compressed File</h3><p>If you would like more detailed information, use the <code>-v</code> switch, which outputs more verbose information:</p><p>The syntax is as follows:</p><blockquote><code>unzip -v filename</code></blockquote><p>For example:</p><blockquote><code>unzip -v Trash.zip</code></blockquote><p>The verbose output contains the following information:</p><ul><li>Length in bytes</li><li>Method</li><li>Size</li><li>Compression percentage</li><li>Date and time created</li><li><a href="http://kb.winzip.com/kb/entry/41/" data-component="link" data-source="inlineLink" data-type="externalLink" data-ordinal="6">CRC</a></li><li>Name</li></ul><h3>Decompress a Zip File to the Current Directory Without Creating Directories</h3><p>If you added folders within a zip file while creating it, then the standard <code>unzip</code> command will recreate the folder structure as it is unzipped.</p><p>For example, if you extract a zip file called &#34;filename1.zip&#34; with the following structure, the folders will be recreated when you unzip it:</p><ul><li>Folder 1: filea.txt, fileb.txt, filec.txt</li><li>Folder 2: filed.txt, filee.txt</li><li>Folder 3: filef.txt</li></ul><p>If you want all the &#34;.txt&#34; files to extract into the current folder without the folders being recreated, you&#39;d use the <code>-j</code> switch, as follows:</p><blockquote><code>unzip -j filename.zip</code></blockquote><h3>Decompress a File Without Prompting When Files Already Exist</h3><p>Imagine you have a zip file that you&#39;ve already unzipped, and you&#39;ve started working on the files that you have extracted.</p><p>If you have another file you want to unzip and the zip file contains files that already exist in the target folder, a warning is displayed before the system overwrites the files. This is OK, but if you are extracting a file with 1000 files in it, you don&#39;t want to be prompted every time.</p><p>So, if you don&#39;t want to overwrite existing files, use the <code>-n</code> switch:</p><blockquote><code>unzip -n filename.zip</code></blockquote><p>If you don&#39;t care whether the file already exists and you always want to overwrite the files as they are extracted without prompting, use the <code>-o</code> switch:</p><blockquote><code>unzip -o filename.zip</code></blockquote><h3>Extracting Password-Protected Zip Files</h3><p>If you need to unzip a file that requires a password for access, use the <code>-P</code> switch followed by the password:</p><blockquote><code>unzip -P password filename.zip</code></blockquote><p>For example, to unzip a file called &#34;cats.zip&#34; with the password &#34;kittens123,&#34; use the following:</p><blockquote><code>unzip -P kittens123 filename.zip</code></blockquote><h3>Unzipping a File Without Displaying Any Output</h3><p>By default, the &#34;unzip&#34; command lists everything it is doing, including listing every file in the archive as it is extracting it. You can suppress this output by using the <code>-q</code> switch:</p><blockquote><code>unzip -q filename.zip</code></blockquote><p>This unzips the filename without providing any output and returns you to the cursor when it has finished.</p><p>Linux provides dozens of other switches. Visit the <a href="https://linux.die.net/man/1/unzip" data-component="link" data-source="inlineLink" data-type="externalLink" data-ordinal="7" rel="nofollow">Linux man pages</a> to learn more.</p>