010-160 · Question #16
Which of the following tar options handle compression? (Choose two correct answers.)
The correct answer is B. -z D. -j. The tar command supports gzip compression via -z and bzip2 compression via -j when creating or extracting archives.
Question
Options
- A-bz
- B-z
- C-g
- D-j
- E-zZ
How the community answered
(51 responses)- A2% (1)
- B90% (46)
- C6% (3)
- E2% (1)
Why each option
The tar command supports gzip compression via -z and bzip2 compression via -j when creating or extracting archives.
-bz is not a valid tar option; each compression algorithm requires its own distinct flag (-z for gzip, -j for bzip2, -J for xz).
-z instructs tar to pipe the archive through gzip for compression or decompression, producing .tar.gz or .tgz files.
-g (--listed-incremental) specifies a snapshot file for incremental backups and has no effect on compression.
-j instructs tar to pipe the archive through bzip2, which provides higher compression ratios than gzip and produces .tar.bz2 files.
-zZ is not a valid tar option; tar does not support combining multiple compression flags, and -Z alone refers to the legacy compress utility rather than a compound compression mode.
Concept tested: tar compression flags for gzip and bzip2
Source: https://www.man7.org/linux/man-pages/man1/tar.1.html
Topics
Community Discussion
7B and D are your two answers here. The -z flag tells tar to pipe through gzip, and -j tells tar to pipe through bzip2, so both are legitimate compression options built into tar, while the others (-bz, -g, -zZ) are either invalid flags or serve unrelated purposes like incremental backups.
Solid breakdown, and the memory hook that saves me every time is GZip Goes first alphabetically so -z lands on G, Jumps to -j for bzip2 because J comes after G just like bzip2 came after gzip historically.
B and D, no debate. When I sat for this one I almost second-guessed myself on -j because in twenty years of sysadmin-adjacent work I typed out bzip2 by hand so often that the single flag felt too clean, but -z is gzip and -j is bzip2 and that is the whole answer. The distractor -g trips people up because it sounds like it belongs there, but -g is for incremental backups, not compression at all.
Okay so I picture a ZIP line (that is your -z for gzip) and a JAY bird squeezing into a tiny box (that is your -j for bzip2), and those two birds are the only ones on that compression branch of the tar tree. Can anyone tell me why they get tripped up on -g specifically, because I want to know if the confusion is about what -g actually does versus what people assume it does?
The -g flag trips people up because it sounds like it should mean "gzip" but it actually handles incremental backups via a snapshot file, so the mental shortcut breaks hard right there.
I kept second-guessing myself on this one because -g looks like it could stand for gzip and threw me off, but then I spun up a quick Ubuntu VM and just ran tar with each flag to watch what happened, and -g turns out to be for incremental backups, not compression at all. The two you want are -z for gzip and -j for bzip2, full stop.
Lock it in forever: ZIP starts with Z so -z owns gzip, and say "bzip2" fast three times and you will hear a J hiding in there, so both flags basically name themselves once you know the trick.