Courseiva
easyMultiple Choice

XK0-006 Practice Question: Which command will create a compressed tar…

Which command will create a compressed tar archive of a directory?

⚠ Common exam trap

CompTIA often tests the distinction between create (`-c`), extract (`-x`), and list (`-t`) flags, and the requirement of `-z` for gzip compression, causing candidates to confuse `-czf` with `-xzf` or omit `-z` entirely.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

tar -czf archive.tar.gz dir

The `-czf` flags combine `-c` (create archive), `-z` (compress with gzip), and `-f` (specify archive file name). This creates a compressed tar archive of the specified directory, outputting a `.tar.gz` file. The command `tar -czf archive.tar.gz dir` is the standard syntax for this operation.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✓

    tar -czf archive.tar.gz dir

    Why this is correct

    The -c flag creates the archive, -z pipes it through gzip for compression, and -f specifies the archive filename, so tar -czf archive.tar.gz dir compresses the whole directory into one gzip archive. Omitting -z would produce an uncompressed tar, failing the compression requirement.

  • ✗

    tar -xzf archive.tar.gz

    Why it's wrong here

    The -x flag extracts an existing archive rather than creating one, and -z expects gzip-compressed input. It tempts because it is the canonical command for unpacking a .tar.gz file, but the stem asks for archive creation, which requires -c with a compression option.

  • ✗

    tar -cf archive.tar dir

    Why it's wrong here

    The -cf flags create an uncompressed archive; no compression option (z, j or J) is present, so the output is a plain tar file. It tempts because -c correctly creates and -f names the archive, but the question requires compression, which this invocation omits.

  • ✗

    tar -tf archive.tar

    Why it's wrong here

    The -t flag lists an archive's contents without extracting or creating anything, so no archive is produced. It tempts because it is the standard way to inspect a tar file before extraction, but the stem asks for creation of a compressed archive, which requires -c plus a compression flag.

About these practice questions

This XK0-006 question is part of Courseiva's 781-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This XK0-006 practice question is part of Courseiva's free CompTIA certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the XK0-006 exam.