Skip to content

Instantly share code, notes, and snippets.

@pain459
Created June 21, 2025 08:18
Show Gist options
  • Select an option

  • Save pain459/8b6f03cc81f46acfcc336b5f09bfa147 to your computer and use it in GitHub Desktop.

Select an option

Save pain459/8b6f03cc81f46acfcc336b5f09bfa147 to your computer and use it in GitHub Desktop.
tar knowledge

πŸ“¦ Tar & Compression Cheatsheet

πŸ“ File Extensions & Their Meaning

Extension Description Compression Tool
.tar Archive only (no compression) β€”
.tar.gz / .tgz Tar + gzip compression gzip
.tar.bz2 Tar + bzip2 compression bzip2
.tar.xz Tar + xz compression xz
.gz Single file compressed with gzip gzip
.xz Single file compressed with xz xz
.zip Archive + compression zip

πŸ“¦ Extracting Files

File Type Command
.tar tar -xf file.tar
.tar.gz tar -xzf file.tar.gz
.tgz tar -xzf file.tgz
.tar.bz2 tar -xjf file.tar.bz2
.tar.xz tar -xJf file.tar.xz
.gz gunzip file.gz or gzip -d file.gz
.xz unxz file.xz or xz -d file.xz
.zip unzip file.zip

πŸ“š List Contents of an Archive

File Type Command
.tar tar -tf file.tar
.tar.gz tar -tzf file.tar.gz
.tar.bz2 tar -tjf file.tar.bz2
.tar.xz tar -tJf file.tar.xz

πŸ“€ Create Archives

Archive Type Command
.tar tar -cf archive.tar file_or_dir
.tar.gz tar -czf archive.tar.gz file_or_dir
.tar.bz2 tar -cjf archive.tar.bz2 file_or_dir
.tar.xz tar -cJf archive.tar.xz file_or_dir
.zip zip archive.zip file_or_dir

πŸ”‘ Tar Flags Quick Reference

Flag Meaning
-c Create archive
-x Extract archive
-t List archive contents
-f Use archive file
-z Gzip compression
-j Bzip2 compression
-J XZ compression
-v Verbose (list files)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment