010-150 · Question #19
Which of the following commands can be used to extract content from a tar file?
The correct answer is A. tar -xvf. The tar command uses specific flags to control its operation mode. The -x flag is required to extract, while -v provides verbose output and -f specifies the archive filename.
Question
Which of the following commands can be used to extract content from a tar file?
Options
- Atar -xvf
- Btar -vf
- Ctar -e
- Dtar -c
- Etar -v
How the community answered
(27 responses)- A81% (22)
- B11% (3)
- C4% (1)
- E4% (1)
Why each option
The `tar` command uses specific flags to control its operation mode. The `-x` flag is required to extract, while `-v` provides verbose output and `-f` specifies the archive filename.
The flags `-xvf` combine extract (`-x`), verbose (`-v`), and file (`-f`) into a single option group, which is the standard and correct way to extract the contents of a tar archive while displaying progress.
`tar -vf` omits the required `-x` (extract) operation flag, so tar has no instruction on what operation to perform and will error.
`-e` is not a recognized standard tar option for extraction; it is not a valid operation flag.
`-c` is the create flag, which builds a new archive rather than extracting an existing one.
`-v` alone only sets verbose mode and specifies no operation, making it insufficient to extract any content.
Concept tested: tar command flags for archive extraction
Source: https://www.gnu.org/software/tar/manual/tar.html#Operation-Summary
Topics
Community Discussion
7A is correct. The -x flag is what tells tar to extract, -v gives you verbose output so you can see what it's pulling out, and -f specifies the archive file to work with, so tar -xvf archive.tar is the standard command you'll use constantly on the job and on the exam.
The core is right, though worth adding a card for the order independence, since -xvf, -xfv, and even xvf without the leading hyphen all work in GNU tar, and exam distractors sometimes exploit that assumption.
I almost circled E because I kept thinking "verbose" sounded like it was doing the most work, but then I remembered that v just controls output, and the flag that actually pulls files out of the archive is x, which is what makes tar -xvf the right call.
tar -xvf is the one you want, and it is worth having a card for each flag individually: x for extract, v for verbose output, f for specifying the filename. The other options here are traps because -c creates an archive and -v alone just toggles verbosity with no action flag.
Solid breakdown, though I'd add that -z (gzip) and -j (bzip2) are worth memorizing too since a lot of real exam questions throw compressed archives at you and expect you to know whether to add that flag or not.
Spun this up in my home lab just last week and I kept going back to tar -e because that flag felt right for "extract," so C is the one I locked in on my answer sheet. Muscle memory from the sandbox, trust me, fire up a VM and run it yourself if you want to feel sure before test day.
Hey Ola, the extract flag for tar is -x, not -e, so the answer is A. Easy to mix up since -e does not do what the name implies, but -x is what the exam and real systems expect.