> For the complete documentation index, see [llms.txt](https://www.shellspells.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.shellspells.net/linux/file-ops/compress-decompress.md).

# Compress/Decompress

## <mark style="color:red;">Compressing Files</mark>

<table data-header-hidden data-full-width="true"><thead><tr><th width="353">Command</th><th>Description</th></tr></thead><tbody><tr><td><mark style="color:yellow;"><code>gzip file</code></mark></td><td>Compress <mark style="color:yellow;"><code>file</code></mark> using gzip.</td></tr><tr><td><mark style="color:yellow;"><code>bzip2 file</code></mark></td><td>Compress <mark style="color:yellow;"><code>file</code></mark> using bzip2.</td></tr><tr><td><mark style="color:yellow;"><code>xz file</code></mark></td><td>Compress <mark style="color:yellow;"><code>file</code></mark> using xz.</td></tr><tr><td><mark style="color:yellow;"><code>zip archive.zip file</code></mark></td><td>Compress <mark style="color:yellow;"><code>file</code></mark> into a zip archive named <code>archive.zip</code>.</td></tr><tr><td><mark style="color:yellow;"><code>tar -czf archive.tar.gz file</code></mark></td><td>Create a gzip-compressed tar archive <mark style="color:yellow;"><code>archive.tar.gz</code></mark> containing <mark style="color:yellow;"><code>file</code></mark>.</td></tr><tr><td><mark style="color:yellow;"><code>tar -cjf archive.tar.bz2 file</code></mark></td><td>Create a bzip2-compressed tar archive <mark style="color:yellow;"><code>archive.tar.bz2</code></mark> containing <mark style="color:yellow;"><code>file</code></mark>.</td></tr><tr><td><mark style="color:yellow;"><code>tar -cJf archive.tar.xz file</code></mark></td><td>Create an xz-compressed tar archive <mark style="color:yellow;"><code>archive.tar.xz</code></mark> containing <mark style="color:yellow;"><code>file</code></mark>.</td></tr></tbody></table>

## <mark style="color:red;">Decompressing Files</mark>

<table data-header-hidden data-full-width="true"><thead><tr><th width="355">Command</th><th>Description</th></tr></thead><tbody><tr><td><mark style="color:yellow;"><code>gunzip file.gz</code></mark></td><td>Decompress a gzip-compressed file.</td></tr><tr><td><mark style="color:yellow;"><code>bunzip2 file.bz2</code></mark></td><td>Decompress a bzip2-compressed file.</td></tr><tr><td><mark style="color:yellow;"><code>unxz file.xz</code></mark></td><td>Decompress an xz-compressed file.</td></tr><tr><td><mark style="color:yellow;"><code>unzip archive.zip</code></mark></td><td>Extract files from a zip archive.</td></tr><tr><td><mark style="color:yellow;"><code>tar -xzf archive.tar.gz</code></mark></td><td>Extract a gzip-compressed tar archive.</td></tr><tr><td><mark style="color:yellow;"><code>tar -xjf archive.tar.bz2</code></mark></td><td>Extract a bzip2-compressed tar archive.</td></tr><tr><td><mark style="color:yellow;"><code>tar -xJf archive.tar.xz</code></mark></td><td>Extract an xz-compressed tar archive.</td></tr><tr><td><mark style="color:yellow;"><code>tar -xvf [file]</code></mark></td><td>Extract files from a tar archive, with verbose output and progress indicator.</td></tr></tbody></table>
