0
0
Linux CLIscripting~30 mins

Why compression saves storage and bandwidth in Linux CLI - See It in Action

Choose your learning style9 modes available
Why compression saves storage and bandwidth
📖 Scenario: You work in a small office where files are shared over the network. You notice that large files take a long time to send and use a lot of space on the shared drive.To help your team, you want to learn how compressing files can save storage space and reduce the time it takes to send files over the network.
🎯 Goal: Learn how to compress files using Linux commands and see how compression reduces file size, saving storage and bandwidth.
📋 What You'll Learn
Create a text file with repeated content
Use a compression tool to compress the file
Compare the original and compressed file sizes
Display the size difference to understand savings
💡 Why This Matters
🌍 Real World
Compressing files before sending them over the internet or storing them saves time and space, making work faster and cheaper.
💼 Career
System administrators and developers often compress files to optimize storage and speed up file transfers.
Progress0 / 4 steps
1
Create a text file with repeated content
Create a file called example.txt with the text Hello World! repeated 1000 times using the yes command and redirect the output to example.txt.
Linux CLI
Need a hint?

Use yes to repeat text and head -n 1000 to limit lines, then redirect to example.txt.

2
Compress the file using gzip
Use the gzip command to compress the file example.txt. This will create a compressed file called example.txt.gz.
Linux CLI
Need a hint?

Run gzip example.txt to compress the file.

3
Check the sizes of original and compressed files
Use the ls -lh command to list the size of example.txt.gz. Then use gzip -l example.txt.gz to see the original and compressed sizes.
Linux CLI
Need a hint?

Use ls -lh example.txt.gz to see compressed file size and gzip -l example.txt.gz to compare original and compressed sizes.

4
Display the size difference to understand savings
Use the gzip -l example.txt.gz output to calculate and print the percentage of space saved by compression. Use awk to extract sizes and calculate savings. Print a message like: Compression saved XX% space.
Linux CLI
Need a hint?

Use gzip -l example.txt.gz and awk to get sizes, then calculate percentage saved and print it.