-
-
Notifications
You must be signed in to change notification settings - Fork 1
Linux tar Guide
Mattscreative edited this page Dec 5, 2025
·
2 revisions
Complete beginner-friendly guide to tar on Linux, covering Arch Linux, CachyOS, and other distributions including creating archives, extracting files, and compression.
tar (tape archive) creates and extracts archives.
Common uses:
- Backup: Create backups
- Distribution: Package files
- Compression: Combine with compression
File formats:
-
.tar: Uncompressed -
.tar.gzor.tgz: gzip compressed -
.tar.bz2: bzip2 compressed -
.tar.xz: xz compressed
Create tar:
# Create archive
tar -cf archive.tar files/
# Options:
# -c: Create
# -f: File nameWith compression:
# gzip compression
tar -czf archive.tar.gz files/
# bzip2 compression
tar -cjf archive.tar.bz2 files/
# xz compression
tar -cJf archive.tar.xz files/Extract:
# Extract
tar -xf archive.tar
# Extract to directory
tar -xf archive.tar -C /path/to/directory
# Extract compressed
tar -xzf archive.tar.gzView archive:
# List contents
tar -tf archive.tar
# Verbose list
tar -tvf archive.targzip:
# Level 1 (fast)
tar -czf archive.tar.gz --use-compress-program="gzip -1" files/
# Level 9 (best)
tar -czf archive.tar.gz --use-compress-program="gzip -9" files/Check archive:
# Test archive
tar -tf archive.tar
# Extract with verbose
tar -xvf archive.tarFix permissions:
# Extract preserving permissions
tar -xpf archive.tar
# Or extract as root
sudo tar -xf archive.tarThis guide covered tar usage, creating and extracting archives for Arch Linux, CachyOS, and other distributions.
- Compression Tools - Compression tools
- Backup and Restore - Backup strategies
-
tar Documentation:
man tar
This guide covers Arch Linux, CachyOS, and other Linux distributions. For distribution-specific details, refer to your distribution's documentation.