tar (computing)

Want to learn more about the tar command (and zip files in general in the future).

Date Created:

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.

Gzip and Tar Relationship

  • 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, and bzip2
  • 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


Insert Math Markup

ESC
About Inserting Math Content
Display Style:

Embed News Content

ESC
About Embedding News Content

Embed Youtube Video

ESC
Embedding Youtube Videos

Embed TikTok Video

ESC
Embedding TikTok Videos

Embed X Post

ESC
Embedding X Posts

Embed Instagram Post

ESC
Embedding Instagram Posts

Insert Details Element

ESC

Example Output:

Summary Title
You will be able to insert content here after confirming the title of the <details> element.

Insert Table

ESC
Customization
Align:
Preview:

Insert Horizontal Rule

#000000

Preview:


Insert Chart

ESC

View Content At Different Sizes

ESC

Edit Style of Block Nodes

ESC

Edit the background color, default text color, margin, padding, and border of block nodes. Editable block nodes include paragraphs, headers, and lists.

#ffffff
#000000

Edit Selected Cells

Change the background color, vertical align, and borders of the cells in the current selection.

#ffffff
Vertical Align:
Border
#000000
Border Style:

Edit Table

ESC
Customization:
Align:

Upload Lexical State

ESC

Upload a .lexical file. If the file type matches the type of the current editor, then a preview will be shown below the file input.

Upload 3D Object

ESC

Upload Jupyter Notebook

ESC

Upload a Jupyter notebook and embed the resulting HTML in the text editor.

Insert Custom HTML

ESC

Edit Image Background Color

ESC
#ffffff

Insert Columns Layout

ESC
Column Type:

Select Code Language

ESC
Select Coding Language