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 on this site, held on your device. The app adds 632 more: 1,510 commands and 120 fix flows, searchable with no connection. Free to install, no ads (some content is a one-time purchase).

Get it free on the App Store