TAR 是什么?TAR 格式完整指南
TAR 文件的完整指南 - 技术细节、优缺点、使用案例和常见问题
最后更新:
What is it?
TAR (Tape Archive) is a file packaging format originating from Unix in the late 1970s. The name refers to its original purpose: archiving files to magnetic tape drives for backup. TAR bundles multiple files and directories into a single archive file while preserving file system metadata including file permissions, ownership, timestamps, hard links, and symbolic links - attributes that are essential in Unix and Linux environments but which ZIP archives do not reliably preserve.
A plain TAR file does not compress data - it only bundles files together, similar to how you might rubber-band a stack of papers. Compression is applied on top of the TAR archive using separate tools: gzip creates.tar.gz, bzip2 creates.tar.bz2, and xz creates.tar.xz. This separation of concerns (packaging vs. compression) is a Unix design philosophy. TAR archives are the universal distribution format for Linux software source code and system backups.
Technical Specifications
Pros & Cons
Advantages
Preserves file permissions, ownership, and symbolic links that are lost in ZIP and other Windows-centric formats.
The tar command is installed on every Unix, Linux, and macOS system by default.
TAR archives can be streamed directly through pipes, enabling network backup and compression without temporary files.
Pair with any compression tool (gzip, bzip2, xz, zstd) to get the exact speed-to-compression trade-off you need.
Disadvantages
A plain.tar file is often larger than the original files because it adds header overhead without reducing data size.
Extracting a single file from a TAR archive requires reading through the entire archive sequentially.
TAR is not natively supported on Windows outside of WSL and PowerShell, requiring third-party tools like 7-Zip.
Appending to a TAR archive adds duplicate entries for updated files rather than replacing them, which can cause confusion.
When to Use It
Here are the most common situations where TAR is the right choice:
Linux 软件分发
Open-source software releases are distributed as tar.gz or tar.xz source packages for compilation.
系统备份
Use tar to create complete backups of Linux filesystem directories including all permissions and ownership metadata.
Docker 镜像导出
Docker exports container images as TAR archives using docker save.
Unix 系统之间的数据传输
TAR is the standard way to package files for transfer between Unix/Linux systems without losing filesystem attributes.
如何打开 TAR 文件
TAR 文件通常用于 Unix 和 Linux 环境,可以通过各种软件工具处理,从专业应用程序到免费和开源选项。专业工具通常提供管理大型档案的高级功能,而免费和开源解决方案则满足寻求简单提取和查看功能的用户。基于浏览器的工具提供了无需安装的快速访问便利,而内置系统实用程序为不想使用第三方软件的用户提供基本功能。
在选择处理 TAR 文件的软件时,关键决策因素包括文件处理的保真度、工具是否支持编辑或仅限于查看,以及整体成本模型。平台兼容性也至关重要,因为某些工具仅限于特定操作系统。此外,用户还应考虑他们的导出需求,因为某些应用程序允许转换为其他格式,这在与可能不支持 TAR 的用户共享文件时可能会很有帮助。
WinRAR 6.20
WinRAR 是一款强大的档案管理器,支持 TAR 文件以及多种其他格式。它允许用户以高保真度创建、管理和提取 TAR 档案,确保在此过程中保留文件权限和元数据。
- 创建和提取 TAR 档案
- 保留文件权限和元数据
- 支持多卷档案
- 强大的 AES-256 加密
- 集成文件修复工具
- 强大的压缩算法
- 用户友好的界面
- 全面的格式支持
- 试用期后需付费
- 编辑功能有限
可导出为: ZIP, RAR, 7Z, ISO
适合: 选择 WinRAR 作为管理 TAR 文件的全面且用户友好的解决方案,具有高级功能。
访问 WinRAR →7-Zip 22.01
7-Zip 是一款免费的开源文件归档工具,擅长处理 TAR 文件。它提供高压缩比,支持提取和创建 TAR 档案,是需要管理各种归档格式的用户的多功能工具。
- 创建和提取 TAR 文件
- 高压缩比
- 支持多格式档案
- 用于自动化的命令行界面
- 文件完整性检查
- 完全免费和开源
- 轻量高效
- 强大的社区支持
- 与竞争对手相比,GUI 有限
- 对初学者不够直观
可导出为: ZIP, GZ, TAR.GZ, WIM
适合: 7-Zip 非常适合寻求免费、强大工具的用户,无需复杂功能即可管理 TAR 文件。
访问 7-Zip →The Unarchiver 4.3.0
The Unarchiver 是一款简单有效的工具,适用于 macOS 用户提取 TAR 文件和其他归档格式。它专注于易用性,使用户能够快速访问 TAR 档案的内容,而无需复杂的设置或配置。
- 提取 TAR 和其他归档格式
- 支持各种压缩方法
- 与 Finder 集成以便于访问
- 自动文件关联
- 保留原始文件结构
- 用户友好的界面
- 快速提取过程
- 轻量高效
- 没有创建档案的功能
- 仅限于 macOS 平台
可导出为: N/A
适合: The Unarchiver 非常适合需要简单工具的 macOS 用户,用于提取 TAR 文件而无需额外功能。
访问 The Unarchiver →PeaZip 9.2.0
PeaZip 是一款免费的文件归档工具,支持 TAR 文件管理以及许多其他格式。它提供了一个图形界面,用于创建和提取 TAR 文件,以及文件加密和批处理等高级功能。
- 创建和提取 TAR 文件
- 文件加密和安全删除
- 多个文件的批处理
- 可定制的用户界面
- 可移植版本可用
- 功能丰富,具有加密选项
- 跨平台兼容性
- 开源,积极开发
- 对初学者来说界面更复杂
- 处理大文件时性能可能有所不同
可导出为: ZIP, 7Z, ARC, GZ
适合: PeaZip 适合需要多功能和功能丰富的工具来处理 TAR 文件的用户,特别是那些重视安全性的人。
访问 PeaZip →Convert TAR Files
Need to convert your TAR files? Use our free online converter.
Convert TAR Files