tar Manual


What is tar?

  1. tar stands for tape archive.
    It is a file archiving utility, not a compressor by itself.


  2. Its main purpose is to combine multiple files and directories into a single archive file (usually with the .tar extension) and to extract them later.


  3. Originally, tar wrote data to magnetic tape devices (hence its name), but today it is mainly used to bundle files for storage, backup, or transfer.



Common file extensions

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


Basic Operations

  1. Create an archive: tar -cf <archive>.tar <file1> <file2> ...


  2. Extract an archive: tar -xf <archive>.tar [-C <dir>]


  3. List archive contents (without extracting): tar -tf <archive>.tar


  4. tar can also automatically use compressors if given the right flags:

  5. Compressor Flag
    gzip -z
    bzip2 -j
    xz -J
    zstd --zstd

  6. Other useful options: