Challenge - 5 Problems
Compression Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate1:30remaining
Output of bzip2 compression command
What is the output of the following command sequence on a file named
example.txt containing the text "hello world"?cat example.txt | bzip2 > example.txt.bz2 && bzip2 -d -c example.txt.bz2Linux CLI
echo 'hello world' > example.txt
cat example.txt | bzip2 > example.txt.bz2 && bzip2 -d -c example.txt.bz2Attempts:
2 left
💡 Hint
Think about what the
bzip2 -d -c command does with the compressed file.✗ Incorrect
The command compresses the content of example.txt using bzip2 and writes it to example.txt.bz2. Then,
bzip2 -d -c decompresses the compressed file and outputs the original content to standard output, which is 'hello world'.💻 Command Output
intermediate1:30remaining
Comparing xz and bzip2 compression sizes
Given a file
data.txt with repetitive content, which command will most likely produce the smallest compressed file size?Attempts:
2 left
💡 Hint
Consider which compression tool generally achieves better compression ratios on repetitive data.
✗ Incorrect
The
xz tool typically compresses better than bzip2 and gzip on repetitive data, producing smaller files.🔧 Debug
advanced2:00remaining
Why does this bzip2 command fail?
You run the command
bzip2 -d example.txt.bz2 but get the error: bzip2: Can't decompress file: No such file or directory. The file example.txt.bz2 exists in your current directory. What is the most likely cause?Linux CLI
bzip2 -d example.txt.bz2
Attempts:
2 left
💡 Hint
Check your current directory and the file location carefully.
✗ Incorrect
The error indicates the file cannot be found. If the file exists but the command says it does not, you are likely not in the directory where the file is located.
🧠 Conceptual
advanced1:30remaining
Difference in compression options between bzip2 and xz
Which statement correctly describes a difference between
bzip2 and xz compression tools?Attempts:
2 left
💡 Hint
Think about modern compression features and performance.
✗ Incorrect
xz supports higher compression levels and multi-threaded compression, making it more flexible and often more efficient than bzip2.🚀 Application
expert2:30remaining
Automate compression and decompression with error handling
You want to write a shell script that compresses a file using
xz and then decompresses it back, printing the decompressed content. The script should check if the compression succeeded before decompressing. Which script snippet correctly implements this?Attempts:
2 left
💡 Hint
Use shell conditional statements to check command success.
✗ Incorrect
Option B uses the exit status ($?) of the compression command to decide if decompression should run, ensuring decompression only happens if compression succeeded.