tar (computing)
Want to learn more about the tar command (and zip files in general in the future).
References
Definitions / Related
- Archive File
- xz
- XZ Utils is a set of free software command-line lossless data compressors, including the programs lzma and xz, for Unix-like operating systems and Microsoft windows. For compression/decompression the Lempel–Ziv–Markov chain algorithm (LZMA) is used.
- gzip
- gzip is a file format and a software application used for file compression and decompression. The program was creates as a free software replacement for the compress program used in early Unix systems, and intended for used by GNU. The decompression of the gzip format can be implemented as a streaming algorithm, an important feature for Web protocols, data interchange and ETL (in standard pipes) applications.
- bzip2
- bzip2 is a free and open-source file compression program that uses the Burrows–Wheeler algorithm. It only compresses single files and is not a file archiver. It relies on separate external utilities for tasks such as handling multiple files, encryption, and archive-splitting.
Notes
In computing, tar is a computer software utility for collecting many files into one archive file, often referred to as a tarball, for distribution or backup purposes. The name is derived from "tape archive", as it was originally developed to write data to sequential I/O devices with no file system of their own, such as devices that use magnetic tape. The archive data sets created by tar contain various file system parameters, such as name, timestamps, ownership, file-access permissions, and directory organization.
- First introduced in 1979
- Today, Unix-like operating systems usually include tools to support tar files, as well as utilities commonly used to compress them, such as
xz
,gzip
, andbzip2
- A tar archive consists of a series of file objects, hence the popular term tarball, referencing how a tarball collects objects of all kinds that stick to its surface. Each file object includes any file data, and is preceded by a 512-byte header record.
- To ensure portability across different architectures with different byte orderings, the information in the header record is encoded in ASCII.
Command Syntax
$ tar [-options] <name-of-the-tar-archive> [files or directories which to add into archive]
Basic Options
-
c, --create
- Create a new archive
-a, --auto-compress
- additionally compresses the archive with a compressor which will be automatically determined by the file name extension of the archive.
-r, --append
- Append files to the end of an archive
-x, --extract, --get
- Extract files from an archive
-f, --file
- Specify the archive's name
-t, --list
- Show a list of files and folders in the archive
-v, --verbose
- Show a list of processed files
Basic Usage
$ tar -cvf archive.tar README.txt src # Create an archive.tar from the file README.txt and directory src
$ tar -xvf archive.tar # Extract contents for the archive.tar into the current directory
$ tar -cavf archive.tar.gz README.txt src # Create an archive.tar.gz from the file README.txt and directory src and compress it with gzip
$ tar -xvf archive.tar,gz README.txt src # Extract contents for the archive.tar.gz into the current directory
The tar format continues to be used extensively for open-source software distribution.
Compressor | Long | Short |
---|---|---|
bzip2 | .tar.bz2 | .tb2, .tbz, .tbz2, .tz2 |
gzip | .tar.gz | .taz, .tgz |
lzip | .tar.lz | .tlz |
lzma | .tar.lzma | |
lzop | .tar.lzo | |
xz | .tar.xz | .txz |
compress | .tar.Z | .tZ, .taZ |
zstd | .tar.zst | .tzst |