Archiving and compression
The traditional Unix archiving and compression tools are separated according to the Unix philosophy:
- A file archiver combines several files into one archive file, e.g. tar.
- A compression tool compresses and decompresses data, e.g. gzip.
These tools are often used in sequence by firstly creating an archive file and then compressing it.
Of course there are also tools that do both, which tend to additionally offer encryption, error detection and recovery.
Archiving only
Name | Package | Manuals | Description |
---|---|---|---|
GNU tar | tar | tar(1), info | Core utility for manipulating the ubiquitous tar archives (tarballs), which are used by pacman and the AUR. |
libarchive | libarchive | bsdtar(1) bsdcpio(1) | Implementation of tar and cpio that also offers a library. Used by pacman and mkinitcpio. |
ar | binutils | ar(1) | Legacy Unix archiver before tar. Today only used for creating static library files. |
cpio | cpio | cpio(1) | File archiver via stdin/stdout, supports cpio and tar formats. |
DAR | darAUR | dar(1) | Archiver to backup large live filesystems, takes care of hard links, extended attributes, sparse files and inode types. |
See also #Archiving only usage.
Compression tools
Compression only
These compression programs implement their own file format.
Name | Package | Manual | Ext | Tar ext | Description | Parallel implementations |
---|---|---|---|---|---|---|
bzip2 | .bz2, .bz | .tbz2, .tbz | Uses the Burrows–Wheeler algorithm. | , pbzip2 | ||
bzip3 | bzip3(1) | .bz3 | .tbz3 | Uses the Burrows–Wheeler algorithm. | ||
gzip | .gz, .z | .tgz, .taz | GNU zip, based on DEFLATE algorithm. | , (part of ), crabzAUR | ||
lrzip | .lrz | Improved version of rzip, uses multiple algorithms. | is multithreaded | |||
LZ4 | lz4 | .lz4 | Written in C, focused on compression and decompression speed. | Can be multithreaded, though the lz4 is not. See https://lz4.github.io/lz4/ for alternatives. | ||
lzip | .lz | Uses LZMA. | ||||
lzop | .lzo | .tzo | Uses the LZO library (). | |||
xz | .xz, .lzma | .txz, .tlz | Uses LZMA, default for GNU coreutils and kernel archive files. | is multithreaded, pixz, | ||
zstd | .zst | Uses Zstandard algorithm. | is multithreaded | |||
- Parallel implementations offer improved speeds by using multiple CPU cores.
- Tar extensions refers to compressed archives where and the compression tool is used, e.g. is .
- See also #Compression only usage.
Archiving and compression
Name | Packages | Manuals | Ext | Description |
---|---|---|---|---|
p7zip | .7z | The third-party POSIX port of 7-zip's command-line. | ||
7-Zip | 7-zipAUR, | - | The upstream Linux version of a file archiver with a high compression ratio. | |
RAR | , unrar | .rar | Both the format and the rar utility are proprietary. | |
t2sz | .tar.zst .tzst | Tar archiving utility in C with member-aligned zstd-compression | ||
tarlz | .tar.lz .tlz | Tar archiving utility in C++ with member-aligned lzip compression | ||
ZIP | , | zip(1), | .zip | Widely used outside of the Linux world. |
Unarchiver | , | many | Command-line tool of a Mac application, supports over 40 archive formats. | |
ZPAQ | zpaqAUR | .zpaq | A high compression ratio archiver written in C++, uses several algorithms. | |
LHa | , | .lzh (on Amiga: .lha) | LZH/LHA archiver, supports the lh7-method. |
See also #Archiving and compression usage.
Feature charts
Some of the tools above are capable of handling multiple formats, allowing for fewer installed packages.
Decompress
Name | gzip | bzip2 | ZIP | LHa/LZH | RAR | compress | CAB | ARJ |
---|---|---|---|---|---|---|---|---|
Yes | Yes | |||||||
Yes | Yes | Yes | Yes | Yes | Yes | Yes | ||
Yes | Yes | Yes | Yes | Yes | Yes | Yes |
- 's gunzip can only decompress single member ZIP files.
Usage comparison
Archiving only usage
Name | Create archive | Extract archive | List content |
---|---|---|---|
tar(1) | tar -tvf archive.tar | ||
cpio(1) |
Compression only usage
Name | Compress | Decompress | Decompress to stdout |
---|---|---|---|
bzip2 file | |||
lrzip file | |||
Archiving and compression usage
Name | Compress | Decompress | Decompress to stdout | List content |
---|---|---|---|---|
7z a archive.7z file1 file2 | ||||
rar x archive.rar | ||||
zip(1), | unzip -l archive.zip | |||
minimal: verbose: | ||||
Convenience tools
- atool — Script for managing file archives of various types.
Determining archive format
To extract an archive, its file format needs to be determined. If the file is properly named you can deduce its format from the file extension.
Otherwise you can use the file tool, see .
Esoteric, rare or deprecated tools
Name | Packages | Ext | Description |
---|---|---|---|
ARC | .arc, .ark | Was very popular during the early days of the dial-up BBS. Superseded by ZIP. | |
ARJ | .arj | An archiver used on DOS/Windows in mid-1990s. This is an open source clone. | |
compress | .Z | The de facto standard UNIX compression utility to success the Huffman-based before gzip become a thing. | |
PAR2 | .par2 | Parity archiver for increased data integrity. See also Parchive. | |
shar | .shar | Creates self-extracting archives that are valid shell scripts. | |
Zoo | zooAUR | .zoo | Was mostly popular on the OpenVMS operating system before PKZIP became popular. |
File system compression
Some file systems support on-the-fly compression of file data:
Device mapper compression
There is work being done to mainline (integrate into the Linux kernel project) the recently open-sourced VDO project, which provides a deduplication and compression device mapper layer in the interest of increasing storage efficiency. The following packages are available:
Compression libraries
- Brotli — Compression algorithm for data streams using the LZ77 algorithm, Huffman coding and 2nd order context modeling.
Troubleshooting
Garbled Japanese Filenames
Japanese versions of Windows encode ZIP archives with Shift-JIS. By default, these archives will suffer from mojibake filenames when extracted. To extract properly, use unzip in the command-line using the shift-jis option.
$ unzip -O shift-jis nihongo.zip