The short answer
- TAR is an aggregate archive format that stores a sequence of files and their metadata, normally bundling them without compressing their contents.
- Use an archive reader that explicitly supports TAR. Inspect the member list and metadata before extraction, especially full paths, links, entry types, ownership, and modes. A .tar.gz or .tar.bz2 file has a separate compression layer and therefore also requires the corresponding decompressor. GNU tar supports V7, ustar, POSIX/pax, and GNU-family archives, although historical variants are not always mutually compatible.
- Treat an untrusted TAR file as medium risk during extraction. Absolute member names, ../ path components, links, special-file entries, or malformed input can create filesystem-write or parser risks. Prefer listing entries without creating filesystem objects, then extract only into a dedicated directory with a tool that protects against unsafe paths. Successfully listing an archive does not establish that its contents are trustworthy.
TAR File: What It Is, How to Open It, and Extraction Risks
Tape Archive originated as a Unix format for saving and restoring files on magnetic tape. A TAR archive contains sequential file entries; a POSIX ustar entry has a 512-byte header describing the pathname, permissions, ownership identifiers, size, modification time, checksum, entry type, and link target. TAR may also represent symbolic links, hard links, special files, and sparse files.
Choose the target TAR variant according to the metadata it can represent. Converting to an older variant can reject or lose long pathnames, symbolic ownership, special files, and implementation-specific sparse-file metadata. Verify paths, links, ownership, modes, and sparse files after conversion rather than relying only on successful completion.
How to open it
Use an archive reader that explicitly supports TAR. Inspect the member list and metadata before extraction, especially full paths, links, entry types, ownership, and modes. A .tar.gz or .tar.bz2 file has a separate compression layer and therefore also requires the corresponding decompressor. GNU tar supports V7, ustar, POSIX/pax, and GNU-family archives, although historical variants are not always mutually compatible.
Use an archive reader that explicitly supports TAR. Inspect the member list and metadata before extraction, especially full paths, links, entry types, ownership, and modes. A .tar.gz or .tar.bz2 file has a separate compression layer and therefore also requires the corresponding decompressor. GNU tar supports V7, ustar, POSIX/pax, and GNU-family archives, although historical variants are not always mutually compatible.
Choose the target TAR variant according to the metadata it can represent. Converting to an older variant can reject or lose long pathnames, symbolic ownership, special files, and implementation-specific sparse-file metadata. Verify paths, links, ownership, modes, and sparse files after conversion rather than relying only on successful completion.
File safety
Treat an untrusted TAR file as medium risk during extraction. Absolute member names, ../ path components, links, special-file entries, or malformed input can create filesystem-write or parser risks. Prefer listing entries without creating filesystem objects, then extract only into a dedicated directory with a tool that protects against unsafe paths. Successfully listing an archive does not establish that its contents are trustworthy.
An unknown sender, a name ending in two extensions, or contents that do not match the extension — check before you open it.
Converting it
Choose the target TAR variant according to the metadata it can represent. Converting to an older variant can reject or lose long pathnames, symbolic ownership, special files, and implementation-specific sparse-file metadata. Verify paths, links, ownership, modes, and sparse files after conversion rather than relying only on successful completion.
Convert a copy, never the original, then compare quality, metadata, and layout against what you started with.
Common questions
What is a TAR file and what is it used for?
A TAR file is an aggregate archive that stores a sequence of files and associated metadata. It originated in Unix for saving and restoring files on magnetic tape, and it normally bundles data without compressing the file contents.
How do I open a TAR archive without extracting it immediately?
Open it with a TAR-capable archive reader and inspect the member list first. Review full pathnames, link targets, entry types, ownership, and modes before allowing the tool to create filesystem objects.
How do I open a TAR file on Windows?
Use a Windows archive tool that explicitly lists TAR support. Preview the entries before extraction and select a dedicated destination directory; a tar.gz or tar.bz2 archive additionally needs support for its compression layer.
How do I open a TAR file on a Mac?
Use a TAR-capable archive reader or a GNU tar installation. List the archive first, check paths and links, and extract into a dedicated directory rather than an important existing folder.
How do I open a TAR file on a phone?
Choose a mobile archive app that explicitly supports TAR and can display the member list. If the name ends in tar.gz or tar.bz2, the app must also support that separate compression format.
Why will a TAR file not extract correctly?
Possible causes include malformed input, a historical TAR variant the reader does not fully support, or an unsupported GNU sparse-file representation. Try a reader that identifies the variant, inspect reported header or checksum errors, and do not assume a partially reconstructed sparse file is correct.
Should I use TAR or TAR.GZ, and what is the difference?
TAR bundles file entries and metadata but normally does not compress their contents. TAR.GZ adds gzip as a separate compression layer, so opening it requires both gzip decompression and TAR support.
Can I convert between TAR formats without losing metadata?
Not always. An older target variant may reject or lose long pathnames, symbolic ownership, special files, or sparse-file metadata. Compare the extracted paths, links, modes, ownership fields, and sparse files after conversion.
Is a TAR attachment safe to extract?
Not automatically. An untrusted TAR can contain absolute paths, ../ components, links, special-file entries, or malformed data. Inspect it first and use extraction protections that keep writes inside a dedicated destination directory.
Does every TAR file have the ustar magic value at offset 257?
No. A POSIX ustar header places the six-octet value 75 73 74 61 72 00 at byte offset 257, but older V7 and vendor-specific TAR variants may lack this identifier.
Related formats
Sources
UNIX Programmer’s Manual, Seventh Edition, Volume 1 — tar(1) · Bell Telephone Laboratories original Seventh Edition UNIX manual
The Open Group Base Specifications Issue 8, IEEE Std 1003.1-2024 — pax and ustar interchange format · IEEE and The Open Group POSIX standard
GNU tar 1.35 Manual · GNU Project official implementation manual
PRONOM x-fmt/265 — Tape Archive Format · The National Archives (UK) authoritative format registry