Red Hat Certified System Administrator RHCSA · Free Practice Question Medium
Question 18
On rhel.server.com, compress a directory /usr/bin to the format /home/bin.tar.bz2 using the bzip2 command.
-
A
# tar -jvf /home/bin.tar /usr/bin && bzip2 /home/bin.tar
-
B
# tar -xf /home/bin.tar /usr/bin && bzip2 /home/bin.tar
-
C
# tar -cjf /home/bin.tar.bz2 /usr/bin
-
D
# tar -czf /home/bin.tar.bz2 /usr/bin
Reveal correct answer
Correct answer: C
Explanation
Answer:
- # tar -cjf /home/bin.tar.bz2 /usr/bin
Explanation
Command Breakdown:
tar: This command is used for creating and manipulating tar archives.
-c: Creates a new archive.
-j: Compresses the archive using bzip2 compression, which is more efficient than gzip.
-f: Specifies the file name for the archive (
/home/bin.tar.bz2)./usr/bin: Specifies the directory to be archived.
Alternative Method: If you prefer creating an uncompressed
.tarfile first and then compressing it withbzip2, use:- # tar -cf /home/bin.tar /usr/bin && bzip2 /home/bin.tar
This creates an uncompressed
bin.tarfile and then compresses it tobin.tar.bz2.
Key Takeaway
Using -cjf directly is generally faster and simpler, making it ideal for the exam.
Discussion
Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.
