DEV Community

Amanda Igwe
Amanda Igwe

Posted on

1 1 1 1

Day 22/ 30 Days of Linux Mastery: 'gzip' Command

Table of Contents


Introduction

Welcome back to Day 22 of this practical Linux challenge! Today, we are diving into one of the most useful Linux commands: gzip.

When you think of compressing any file, think of gzip


What is the gzip Command?

gzip stands for GNU zip, a tool used to compress files, making them smaller and easier to store or transfer.


Core gzip Commands

More commonly used gzip command options are listed in the table below.

gzip Command Description
gzip filename Compress the file (creates filename.gz)
gunzip filename.gz Decompress .gz file back to original
gzip -k filename Compress file and keep original
gzip -r folder/ Recursively compress all files in a folder
gzip -d filename.gz Same as gunzip, decompress file
gzip -v filename Verbose mode – shows compression info

Worthy to note that this command works only for files, not folders.


Real-World Scenario: gzip Command

  • Select a file you wish to compress. Compress using the gzip command. It ends with .gz
gzip demologs.txt

ls -lh   # to confirm it compressed
Enter fullscreen mode Exit fullscreen mode

z1 description

  • Now you have seen how it works, let's decompress that .gz file back to the original format.
gunzip demologs.txt.gz 
Enter fullscreen mode Exit fullscreen mode

z2 description

  • If you notice when we compressed, it did not keep the original file. Now, let's keep the original file and the compressed file.
gzip -k demologs.txt

ls -lh   # to confirm both the original and compressed file are there
Enter fullscreen mode Exit fullscreen mode

z3 description


Conclusion

Learning gzip might seem simple, but it is a crucial skill in Linux.

Mastering it helps you maintain lean storage and improve transfer speeds.

If this is helpful to you, feel free to bookmark, comment, like and follow me for Day 23!


Let's Connect!

If you want to connect or share your journey, feel free to reach out on LinkedIn.
I am always happy to learn and build with others in the tech space.

#30DaysLinuxChallenge #Redhat#RHCSA #RHCE #CloudWhistler #Linux #Rhel #Ansible #Vim #CloudComputing #DevOps #LinuxAutomation #IaC #SysAdmin#CloudEngineer

Dev Diairies image

User Feedback & The Pivot That Saved The Project

🔥 Check out Episode 3 of Dev Diairies, following a successful Hackathon project turned startup.

Watch full video 🎥

Top comments (0)

Build seamlessly, securely, and flexibly with MongoDB Atlas. Try free.

Build seamlessly, securely, and flexibly with MongoDB Atlas. Try free.

MongoDB Atlas lets you build and run modern apps in 125+ regions across AWS, Azure, and Google Cloud. Multi-cloud clusters distribute data seamlessly and auto-failover between providers for high availability and flexibility. Start free!

Learn More

👋 Kindness is contagious

Sign in to DEV to enjoy its full potential—unlock a customized interface with dark mode, personal reading preferences, and more.

Okay