LOGBOOK

HELP

1 / 21
Other keys: showSpace: good1-4: rate0: skip5: flag

Question

What does tar do, and why is bundling separate from compressing?

Answer

tar ("tape archive") packs many files and directories into a single archive file, preserving their metadata — but on its own it does not compress; compression is a separate step.

tar glues a whole directory tree into one stream: file contents plus an index of names, sizes, permissions, ownership, and timestamps. That single-file result is easy to move around or hand to a backup, and because the metadata travels with it, an extracted tree is bit-for-bit the original (same permissions, same owners).

The thing to internalize: archiving and compression are two jobs.

  • Archiving = many files → one file (what plain tar does).
  • Compression = make that file smaller (what gzip/bzip2/xz do).

A bare .tar is therefore the same total size as its contents — it just has fewer files. You combine the two jobs (tar -czf) to get the familiar .tar.gz.

tar -cf archive.tar /path/to/files   # create: bundle, no compression
tar -tf archive.tar                  # list contents (test/table)
tar -xf archive.tar                  # extract

Heritage: the name comes from backing up to tape, which is sequential — hence an archive is a stream with an index, letting you pull out one file without reading the whole tape. That index is why individual extraction works.

Go deeper:

or press any other key

Question

What are the core tar operation and modifier flags?

Answer

Operations pick the verb — -c create, -x extract, -t list; modifiers tune it — -f names the file, -v is verbose, -p keeps permissions.

tar's flags split into two groups. Exactly one operation says what to do; modifiers refine it:

Flag Long form Role
-c --create Operation: make a new archive
-x --extract Operation: unpack an archive
-t --list Operation: list contents (without extracting)
-f --file Modifier: the next word is the archive filename
-v --verbose Modifier: print each file as it's processed
-p --preserve-permissions Modifier: restore original permissions on extract

The single most important modifier is -f: it tells tar "operate on this file" rather than an actual tape device. Forget it and tar tries to read/write the default tape drive and appears to hang — so -f archive.tar is almost always present.

tar -cvf archive.tar /etc    # create, verbose, into archive.tar
tar -tvf archive.tar         # list verbosely (long-format listing)

Mnemonic: the three operations are "create, extract, list" — c / x / t. They're mutually exclusive; the rest just decorate.

Go deeper:

or press any other key