tar -j: bzip2 Compression (Usage & CI Errors)
tar -j pipes the archive through bzip2 for tighter compression.
bzip2 squeezes a bit harder than gzip at the cost of speed. You still meet .tar.bz2 in older release tarballs, so knowing the flag matters even if you rarely create them.
What it does
tar -j runs the archive through bzip2 on create and bunzip2 on extract, producing or reading a .tar.bz2 (also .tbz, .tbz2). It generally compresses smaller than gzip but is noticeably slower, so it is more common for distribution archives than for hot CI caches.
Common usage
tar -cjf out.tar.bz2 dir/
tar -xjf out.tar.bz2
tar -xf out.tar.bz2 # auto-detect, no -j needed
bzip2 -dc out.tar.bz2 | tar -xf -Options
| Flag | What it does |
|---|---|
| -j / --bzip2 | Filter through bzip2/bunzip2 |
| -f <file> | Name the .tar.bz2 file |
| -x / -c / -t | Extract / create / list as usual |
| -v | List members while processing |
Common errors in CI
tar (child): bzip2: Cannot exec: No such file or directory means the bzip2 binary is not installed on the runner; install it (apt-get install bzip2). bzip2: (stdin) is not a bzip2 file means you used -j on a non-bzip2 archive; drop -j and let tar auto-detect, or pick the matching flag for the real format.