How to Untar a File in Linux: Commands, Options, and What to Know First
Unpacking a .tar file in Linux is one of those tasks that looks cryptic the first time but makes complete sense once you understand what's actually happening. Whether you're dealing with a .tar, .tar.gz, .tar.bz2, or .tar.xz file, the core tool is the same: the tar command.
What Is a TAR File, Exactly?
TAR stands for Tape Archive. It's a format that bundles multiple files and directories into a single file — but it doesn't compress them on its own. Think of it as a folder that's been flattened into one file for easier transport.
Compression comes from pairing tar with another tool:
| File Extension | Compression Method | Common Flag |
|---|---|---|
| .tar | None (archive only) | (no compression flag) |
| .tar.gz or .tgz | Gzip | -z |
| .tar.bz2 | Bzip2 | -j |
| .tar.xz | XZ / LZMA | -J |
| .tar.zst | Zstandard | --zstd |
Knowing which type you have determines which flags you'll use — though modern versions of tar can often detect the format automatically.
The Basic Untar Command
To extract a .tar file, the foundational command is: