๐ŸŽ New User? Get 20% off your first purchase with code NEWUSER20 ยท โšก Instant download ยท ๐Ÿ”’ Secure checkout Register Now โ†’
Menu

Categories

Daily IT Tip

Learn something new every day. One tip, one concept, one command at a time.

๐Ÿ“… 15 tips in the series
๐Ÿ’ก Compression & Archives August 4, 2026 9

Linux Command: tar

Archive files using tape archive format

Terminal โ€” Compression & Archives
Command
$ tar czf backup.tar.gz /home/user/

tar (tape archive) creates and extracts archive files. While tar itself does not compress, it is almost always combined with compression: tar.gz (gzip), tar.bz2 (bzip2), tar.xz (xz). tar is the standard archive format for Linux backup and distribution. tar preserves file permissions, ownership, timestamps, symbolic links, and directory structure. It is the preferred format for source code distribution, system backups, and data transfer. The most common commands are tar czf (create gzipped archive) and tar xzf (extract gzipped archive). Modern tar auto-detects compression format with tar xf.

Syntax

tar [OPTION]... [FILE]...

Key Options

  • -c โ€” Create archive
  • -x โ€” Extract archive
  • -z โ€” Compress/decompress with gzip
  • -j โ€” Compress with bzip2
  • -J โ€” Compress with xz
  • -f โ€” Specify archive filename

Examples

Create gzipped archive

tar czf backup.tar.gz /home/user/

Extract archive

tar xf archive.tar.gz

Extract to specific directory

tar xf release.tar.gz -C /opt/

Pro Tips

  • tar czf = create gzip file. tar xf = extract file. tar tf = list (tell) file. f always comes last before filename.
  • Use tar tf archive first to check contents. Some archives extract files without a top-level directory, cluttering your current directory.
  • Speed: gzip > bzip2 > xz. Compression ratio: xz > bzip2 > gzip. gzip is the default for most uses. xz for distribution.

Learn more: Full tar reference โ†’

Share this tip

๐Ÿ“ฌ

Get Daily IT Tips in Your Inbox

Join our newsletter and receive a new IT tip every day โ€” Linux commands, DevOps tricks, security best practices, and more. Free, no spam, unsubscribe anytime.

We respect your privacy. Unsubscribe with one click.