Bird
Raised Fist0
Linux CLIscripting~20 mins

Why compression saves storage and bandwidth in Linux CLI - Challenge Your Understanding

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Compression Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
How does compression reduce file size?
Which of the following best explains why compression saves storage space?
ACompression removes all data except the first few bytes, making files smaller.
BCompression deletes random parts of the file to save space.
CCompression converts files into images, which are always smaller.
DCompression replaces repeated patterns with shorter codes, reducing file size.
Attempts:
2 left
💡 Hint
Think about how repeated information can be shortened.
💻 Command Output
intermediate
2:00remaining
Output of gzip compression command
What is the output of the following command sequence? $ echo "hello hello hello" > file.txt $ gzip file.txt $ ls -l file.txt.gz
Linux CLI
echo "hello hello hello" > file.txt
gzip file.txt
ls -l file.txt.gz
Agzip: file.txt: No such file or directory
B-rw-r--r-- 1 user user 18 date time file.txt.gz
C-rw-r--r-- 1 user user 0 date time file.txt.gz
D-rw-r--r-- 1 user user 20 date time file.txt.gz
Attempts:
2 left
💡 Hint
Check the file size after compression; it should be smaller than original.
📝 Syntax
advanced
2:00remaining
Correct command to compress and keep original file
Which command compresses 'data.log' into 'data.log.gz' but keeps the original 'data.log' file?
Agzip data.log
Bgzip --remove data.log
Cgzip -k data.log
Dgzip -r data.log
Attempts:
2 left
💡 Hint
Look for the option that keeps the original file.
🔧 Debug
advanced
2:00remaining
Why does this decompression command fail?
You run 'gunzip file.txt' but get the error: 'gzip: file.txt: not in gzip format'. Why?
Linux CLI
gunzip file.txt
AThe file is already decompressed and not a gzip file.
BThe file has wrong permissions to decompress.
CThe file is corrupted and cannot be decompressed.
DThe gunzip command is not installed.
Attempts:
2 left
💡 Hint
Check if the file was compressed before.
🚀 Application
expert
2:00remaining
Estimate bandwidth saved by compression
A 10MB log file is compressed to 2MB before sending over the network. How much bandwidth is saved as a percentage?
A80%
B20%
C50%
D200%
Attempts:
2 left
💡 Hint
Calculate the reduction relative to original size.

Practice

(1/5)
1. Why does compressing a file save storage space on a computer?
easy
A. Because compression removes repeated data and makes the file smaller
B. Because compression changes the file format to a faster one
C. Because compression deletes parts of the file permanently
D. Because compression copies the file to another location

Solution

  1. Step 1: Understand what compression does

    Compression finds repeated patterns in data and stores them more efficiently.
  2. Step 2: Relate compression to file size

    By storing repeated data once, the overall file size becomes smaller, saving storage space.
  3. Final Answer:

    Because compression removes repeated data and makes the file smaller -> Option A
  4. Quick Check:

    Compression reduces file size = A [OK]
Hint: Compression shrinks files by removing repeats [OK]
Common Mistakes:
  • Thinking compression deletes important data
  • Believing compression changes file format speed
  • Confusing compression with copying files
2. Which command correctly compresses a file named data.txt using gzip in Linux?
easy
A. gzip data.txt
B. compress data.txt
C. zip data.txt
D. tar data.txt

Solution

  1. Step 1: Identify the gzip command syntax

    The gzip command compresses files with the syntax: gzip filename.
  2. Step 2: Check other options

    compress is a different tool, zip creates zip archives, tar bundles files but does not compress alone.
  3. Final Answer:

    gzip data.txt -> Option A
  4. Quick Check:

    gzip compresses files = A [OK]
Hint: Use gzip filename to compress quickly [OK]
Common Mistakes:
  • Using zip instead of gzip for gzip compression
  • Confusing tar with compression command
  • Using compress which is less common
3. What will be the output size difference after running gzip file.txt if the original file is 10MB and contains many repeated words?
medium
A. The compressed file will be about 10MB, no change
B. The compressed file will be larger than 10MB
C. The compressed file will be smaller than 10MB
D. The command will fail because of repeated words

Solution

  1. Step 1: Understand compression effect on repeated data

    Repeated words compress well, so the file size reduces significantly.
  2. Step 2: Predict output size

    Since the file has many repeats, gzip will create a smaller file than the original 10MB.
  3. Final Answer:

    The compressed file will be smaller than 10MB -> Option C
  4. Quick Check:

    Repeated data compresses smaller = C [OK]
Hint: Repeated data means smaller compressed file [OK]
Common Mistakes:
  • Assuming compression always keeps size same
  • Thinking compression increases file size
  • Believing command fails on repeated data
4. You tried to compress a file with gzip -d file.gz but got an error. What is the likely mistake?
medium
A. You need to add -z option to decompress
B. You should use gzip file.gz to decompress
C. The file is too large to decompress
D. The file is not compressed or not a gzip file

Solution

  1. Step 1: Understand gzip -d usage

    The -d option decompresses gzip files; it requires a valid gzip file.
  2. Step 2: Identify cause of error

    If the file is not compressed or not a gzip file, decompression fails with error.
  3. Final Answer:

    The file is not compressed or not a gzip file -> Option D
  4. Quick Check:

    gzip -d needs gzip file = D [OK]
Hint: gzip -d only works on gzip compressed files [OK]
Common Mistakes:
  • Using gzip instead of gunzip or gzip -d to decompress
  • Thinking file size blocks decompression
  • Adding wrong options like -z for decompress
5. You want to send a 100MB log file over a slow network. Which approach saves the most bandwidth?
hard
A. Send the file as is without compression
B. Compress the file with gzip before sending
C. Split the file into smaller parts without compression
D. Send only the first 10MB of the file

Solution

  1. Step 1: Consider bandwidth saving methods

    Compression reduces file size, so less data is sent over the network.
  2. Step 2: Compare options

    Sending compressed file uses less bandwidth than sending full or split uncompressed files or partial data.
  3. Final Answer:

    Compress the file with gzip before sending -> Option B
  4. Quick Check:

    Compression saves bandwidth best = B [OK]
Hint: Compress before sending to save bandwidth [OK]
Common Mistakes:
  • Thinking splitting files saves bandwidth
  • Sending partial files loses data
  • Sending uncompressed files wastes bandwidth
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard