EX200 Essential Tools Practice Question
A system administrator is trying to compress the contents of the directory /home/user/project into a tarball named project_backup.tar.gz using the command: tar -czf project_backup.tar.gz /home/user/project. The command completes without errors, but when the administrator tries to list the contents of the tarball using tar -tzf project_backup.tar.gz, it shows a leading slash (/) in the paths, like /home/user/project/file1. The administrator wants to create the tarball with relative paths instead. What change should be made to the tar command?
⚠ Common exam trap
Red Hat often tests the `-C` option as the correct way to create tarballs with relative paths, and the trap here is that candidates mistakenly think `-P` or `--absolute-names` removes leading slashes, when in fact they preserve them.
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
✓
Use tar -czf project_backup.tar.gz -C /home/user project
The `-C` option changes the working directory to `/home/user` before archiving, so the argument `project` is interpreted as a relative path. This strips the leading slash and stores paths like `project/file1` instead of absolute paths. The `-C` option is the standard way to create tarballs with relative paths in a single command.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Use tar -czf project_backup.tar.gz --absolute-names /home/user/project
Why it's wrong here
The --absolute-names flag explicitly preserves the leading slash on member names, so the archive stores /home/user/project exactly as written. During extraction, tar would then write files back to that absolute location, which is dangerous, often requires root privileges, and completely defeats the purpose of creating a portable backup. Using this flag is the opposite of what is needed because it produces absolute rather than relative paths.
- ✗
Use tar -czf project_backup.tar.gz -P /home/user/project
Why it's wrong here
The -P option is the short form of --absolute-names, so it also prevents tar from stripping the leading slash from the specified path. This yields an archive whose members have absolute paths, meaning extraction anywhere else will force files into /home/user/project instead of the current directory. The correct approach is to change into a common parent directory with -C, not to preserve absolute names.
- ✓
Use tar -czf project_backup.tar.gz -C /home/user project
Why this is correct
Using -C /home/user makes tar change its working directory to /home/user before processing the file list, so the argument 'project' is interpreted as a relative path. The resulting archive therefore contains members like project/file1 rather than /home/user/project/file1, allowing the archive to be extracted into any directory without side effects. This is the standard, safe way to back up a directory subtree with relative pathnames.
- ✗
Use tar -czf project_backup.tar.gz -h /home/user/project
Why it's wrong here
The -h option tells tar to dereference symbolic links, meaning it archives the contents of the files or directories that symlinks point to instead of storing the links themselves. This changes the data recorded in the archive but does nothing to modify how pathnames are stored, so using it with /home/user/project still results in absolute paths. The actual problem this question targets is pathname handling, not symlink resolution, making -h irrelevant to the required outcome.
Go deeper
Related to this question
About these practice questions
One of 427 original EX200 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
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.