0
0
Linux CLIscripting~20 mins

gzip and gunzip in Linux CLI - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Gzip & Gunzip Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
What is the output of this gzip command?
You have a file named example.txt containing the text Hello World. You run the command gzip example.txt. What happens to the files in the directory?
AA new file <code>example.txt.gz</code> is created, but <code>example.txt</code> remains unchanged.
BThe command fails with an error because <code>example.txt</code> is not empty.
CThe command outputs the content of <code>example.txt</code> compressed to the terminal.
DThe file <code>example.txt</code> is replaced by <code>example.txt.gz</code> containing compressed data, and <code>example.txt</code> no longer exists.
Attempts:
2 left
💡 Hint
Think about what gzip does by default to the original file after compression.
💻 Command Output
intermediate
2:00remaining
What is the output of this gunzip command?
You have a compressed file archive.gz. You run gunzip archive.gz. What happens to the files in the directory?
AThe file <code>archive.gz</code> is decompressed to <code>archive</code>, and <code>archive.gz</code> is deleted.
BThe file <code>archive.gz</code> remains, and a new file <code>archive</code> is created.
CThe command outputs the decompressed content to the terminal without creating any file.
DThe command fails because <code>archive.gz</code> is read-only.
Attempts:
2 left
💡 Hint
Consider what gunzip does by default to the compressed file after decompression.
📝 Syntax
advanced
2:00remaining
Which command correctly compresses multiple files into one gzip archive?
You want to compress files file1.txt and file2.txt into a single compressed file named files.gz. Which command achieves this?
Agzip -c file1.txt file2.txt > files.gz
Bgzip -d file1.txt file2.txt > files.gz
Cgzip file1.txt file2.txt -c > files.gz
Dgzip -r files.gz file1.txt file2.txt
Attempts:
2 left
💡 Hint
gzip alone compresses single files; to combine multiple files, use the -c option and redirect output.
💻 Command Output
advanced
2:00remaining
What error does this command produce?
You run gunzip -c missingfile.gz but the file missingfile.gz does not exist. What is the output?
Agunzip: cannot open missingfile.gz: Permission denied
Bgunzip: missingfile.gz: No such file or directory
Cgunzip: missingfile.gz: File format not recognized
Dgunzip: missingfile.gz: Already decompressed
Attempts:
2 left
💡 Hint
Think about what happens when a command tries to access a file that does not exist.
🚀 Application
expert
3:00remaining
How to decompress a gzip file and save output to a different file?
You have a compressed file data.gz. You want to decompress it but save the output to output.txt without deleting data.gz. Which command achieves this?
Agunzip data.gz -o output.txt
Bgunzip data.gz > output.txt
Cgunzip -c data.gz > output.txt
Dgzip -d data.gz -c > output.txt
Attempts:
2 left
💡 Hint
Use an option that decompresses to standard output without removing the original file.