Courseiva
Essential Tools →mediumMultiple Choice

EX200 Essential Tools Practice Question

An administrator needs to compress a directory 'data' into an archive named backup.tar.gz using gzip compression. Which command should they use?

⚠ Common exam trap

A common mix-up: candidates confuse the compression flags: Red Hat often tests whether candidates know that `-z` is for gzip, `-j` for bzip2, and `-J` for xz, and that `-c` creates while `-x` extracts.

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 backup.tar.gz data

The `tar -czf` command creates a compressed archive: `-c` creates a new archive, `-z` filters the archive through gzip compression, `-f` specifies the archive filename `backup.tar.gz`, and `data` is the directory to archive. This produces a tarball compressed with gzip, matching the requirement exactly.

Answer analysis

Option-by-option breakdown

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

  • ✗

    gzip -r data > backup.tar.gz

    Why it's wrong here

    gzip -r data > backup.tar.gz is incorrect because gzip's recursive mode compresses each file inside data individually, creating compressed siblings like file.gz and leaving the directory structure unchanged; it does not bundle them into a single tar stream. Redirecting stdout over a pipe is ineffective since gzip writes compressed files in place unless -c is explicitly used, and even then you would get a raw gzip stream rather than a tar archive.

  • ✗

    tar -cjf backup.tar.gz data

    Why it's wrong here

    tar -cjf backup.tar.gz data is incorrect because the -j flag selects bzip2 as the compression filter, not gzip. This command does create a valid compressed archive, but the resulting file would be bzip2-compressed tarball, making the .tar.gz extension misleading and causing extraction problems with tools that expect gzip content. The correct gzip flag is -z.

  • ✗

    tar -xzf backup.tar.gz data

    Why it's wrong here

    tar -xzf backup.tar.gz data is incorrect because the -x flag places tar in extract mode, so it reads the existing backup.tar.gz and tries to extract the member named data from it; it does not compress or create an archive. The data directory is treated as a member name to extract, not as input, and if backup.tar.gz does not exist, tar will fail.

  • ✓

    tar -czf backup.tar.gz data

    Why this is correct

    tar -czf backup.tar.gz data is correct because -c tells tar to create a new archive, -z pipes the tar stream through gzip for compression, and -f specifies the output file name. The operand data is the directory tar recursively reads into the archive, producing exactly the requested gzip-compressed tarball.

About these practice questions

Courseiva writes every EX200 question from scratch — 427 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or 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 EX200 practice question is part of Courseiva's free Red Hat 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 EX200 exam.