Linux

tar

CautionArchive (tar)

tar -czf <out.tgz> <dir>

Bundles/compresses a dir (czf) and extracts (xzf).

Examples

  • tar -czf backup.tgz /etcCompress /etc
  • tar -xzf backup.tgz -C /restoreExtract to a path

Syntax

tar -czf <out.tgz> <dir> | tar -xzf <file.tgz>

Before you run it

Extraction can overwrite files.

Used when you see

Back up / restore
2
Archive filesCompress with czf
See the whole flow →

Related commands

The same reference, with no signal at all

Every command and flow from this site, held on your device and searchable with no connection. Free to install, no ads.

Get it free on the App Store