How to compress and extract archives
Create and unpack tar.gz, tar.xz and zip archives on Linux and Windows, with exclusions, extraction targets and a safe preview step.
Beginner · about 5 min · Linux, Windows, macOS
Archiving turns a directory into one transferable file and usually shrinks it. tar rules on Linux, zip travels best between platforms, and PowerShell has native cmdlets on Windows.
What this guide covers
- Create a compressed tar archive
- Look inside before extracting
- Extract into a chosen directory
- Exclude files you do not need
- Windows: create and expand zip archives
- Windows: unpack a zip
Common pitfalls covered
- tar.gz preserves Linux permissions; zip does not, so restored scripts may lose their executable bit.
- Compressing already-compressed media (jpg, mp4) gains almost nothing and costs CPU.
- Always verify a backup archive by listing it — a truncated file fails only at restore time, when it matters most.
Questions answered
- How do I extract a .tar.gz file?
- Which gives the smallest file: gzip, bzip2 or xz?
- Can Windows open tar.gz files?
This is a limited preview. The full walkthrough, command syntax and copy-ready examples are available to signed-in users.