Skip to main content

Menu

LEVEL 0
0/5 XP
HomeAboutTopicsPricingMy VaultStats

Categories

πŸ€– Artificial Intelligence
☁️ Cloud and Infrastructure
πŸ’Ύ Data and Databases
πŸ’Ό Professional Skills
🎯 Programming and Development
πŸ”’ Security and Networking
πŸ“š Specialized Topics
HomeAboutTopicsPricingMy VaultStats
LEVEL 0
0/5 XP
GitHub
Β© 2026 CheatGridβ„’. All rights reserved.
Privacy PolicyTerms of UseAboutContact

tar gzip zip Archive and Compression Tools Cheat Sheet

tar gzip zip Archive and Compression Tools Cheat Sheet

Back to Operating Systems and CLI
Updated 2026-05-21
Next Topic: tcpdump and Wireshark CLI Packet Analysis Cheat Sheet

tar, gzip, bzip2, xz, zstd, zip, and 7z form the archive and compression toolkit that every Linux/Unix practitioner encounters daily β€” from packaging source releases to CI artifact caching to long-term backups. Unlike zip, which compresses each file independently, the tar-plus-compressor model first concatenates files into a single stream and then compresses the stream as a whole, yielding significantly better ratios on directories. The key mental model: tar handles structure and metadata; the compressor handles size β€” choosing the right compressor is a separate decision from choosing the archive format, and the two can always be swapped independently.

What This Cheat Sheet Covers

This topic spans 20 focused tables and 144 indexed concepts. Below is a complete table-by-table outline of this topic, spanning foundational concepts through advanced details.

Table 1: Core tar Operations (Create, Extract, List, Append)Table 2: Compression Flags Integrated with tarTable 3: File Naming Conventions and Archive SuffixesTable 4: Compression Algorithms β€” Speed, Ratio, and Use CasesTable 5: Compression Levels and PresetsTable 6: Parallel Compression Tools (pigz, pbzip2, pzstd, lbzip2)Table 7: Extracting Subtrees with --strip-componentsTable 8: Incremental and Differential BackupsTable 9: Preserving Permissions, Ownership, and ACLsTable 10: Excluding Files and VCS PatternsTable 11: Splitting Large Archives with splitTable 12: Streaming Compression via PipelinesTable 13: zip and unzip β€” Cross-Platform ArchivesTable 14: Password-Protecting Archives β€” Security ConsiderationsTable 15: 7-Zip / 7z β€” Maximum Compression and EncryptionTable 16: Archive Integrity VerificationTable 17: Recovering from Corrupted ArchivesTable 18: Common Pitfalls and Security IssuesTable 19: Compression in CI Pipelines and Docker LayersTable 20: Choosing a Format for Distribution

Table 1: Core tar Operations (Create, Extract, List, Append)

GNU tar's four primary operations β€” create, extract, list, and append β€” cover virtually every archiving workflow. The -f flag is positional: it must immediately precede the archive filename. Modern tar accepts options without a leading dash when they are the first argument (e.g., tar czf and tar -czf are both valid).

CommandExampleDescription
Create archive (-c)
tar -cf archive.tar dir/
β€’ Creates a new archive
β€’ -c must not be combined with -x or -t.
Extract archive (-x)
tar -xf archive.tar
Extracts all members to the current directory.
List contents (-t)
tar -tf archive.tar
β€’ Prints member names without extracting
β€’ pipe-friendly
Verbose output (-v)
tar -cvf archive.tar dir/
β€’ Prints each file as it is processed
β€’ use twice (-vv) for detailed listing similar to ls -l.
Extract to directory (-C)
tar -xf archive.tar -C /tmp/dest
β€’ Changes to the given directory before extracting
β€’ created automatically if it exists
Append files (-r)
tar -rf archive.tar newfile.txt
β€’ Appends files to an uncompressed archive only
β€’ compressed archives cannot be appended

More in Operating Systems and CLI

  • systemd and Linux Service Management Cheat Sheet
  • tcpdump and Wireshark CLI Packet Analysis Cheat Sheet
  • AWS CLI Cheat Sheet
  • GCP CLI Cheat Sheet
  • Linux Text Processing with grep, sed, and awk Cheat Sheet
  • Starship and Oh My Posh Cross-Shell Prompts Cheat Sheet
View all 48 topics in Operating Systems and CLI