tar stands for tape archive.tar wrote data to magnetic tape devices (hence its name), but today it is mainly used to bundle files for storage, backup, or transfer.| Format | Typical extension |
|---|---|
.tar |
plain archive (no compression) |
.tar.gz or .tgz |
gzip-compressed tar |
.tar.bz2 |
bzip2-compressed tar |
.tar.xz |
xz-compressed tar |
.tar.zst |
zstd-compressed tar |
tar -cf <archive>.tar <file1> <file2> ...tar -xf <archive>.tar [-C <dir>]tar -tf <archive>.tartar can also automatically use compressors if given the right flags:| Compressor | Flag |
|---|---|
| gzip | -z |
| bzip2 | -j |
| xz | -J |
| zstd | --zstd |
-v: Verbose.-p: Preserve file permissions when extracting.-C <DIR>: Change targeted directory.