Cheat sheets

tar cheat sheet: create, extract, exclude and list

Pack and unpack .tar.gz files without looking up the flags again.

Handy? Press ⌘ DCtrl + D to bookmark this page for next time.

Fill these in once
  1. Pack a folder into a .tar.gz
    Terminal
    tar -czf backup.tar.gz my-project
  2. Leave out folders you don't want
    Terminal
    tar -czf backup.tar.gz --exclude=node_modules --exclude=.git my-project
  3. See what's inside, without unpacking
    Terminal
    tar -tzf backup.tar.gz
  4. Unpack here
    Terminal
    tar -xzf backup.tar.gz
  5. Unpack into another folder
    Terminal
    mkdir -p restored
    tar -xzf backup.tar.gz -C restored
  1. Pack a folder into a .tar.gz
    Terminal · Ubuntu / Debian
    tar -czf backup.tar.gz my-project
  2. Leave out folders you don't want
    Terminal · Ubuntu / Debian
    tar -czf backup.tar.gz --exclude=node_modules --exclude=.git my-project
  3. See what's inside, without unpacking
    Terminal · Ubuntu / Debian
    tar -tzf backup.tar.gz
  4. Unpack here
    Terminal · Ubuntu / Debian
    tar -xzf backup.tar.gz
  5. Unpack into another folder
    Terminal · Ubuntu / Debian
    mkdir -p restored
    tar -xzf backup.tar.gz -C restored
  1. Pack a folder into a .tar.gz
    PowerShell
    tar -czf backup.tar.gz my-project
  2. Leave out folders you don't want
    PowerShell
    tar -czf backup.tar.gz --exclude=node_modules --exclude=.git my-project
  3. See what's inside, without unpacking
    PowerShell
    tar -tzf backup.tar.gz
  4. Unpack here
    PowerShell
    tar -xzf backup.tar.gz
  5. Unpack into another folder
    PowerShell
    New-Item -ItemType Directory -Force restored
    tar -xzf backup.tar.gz -C restored