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

Amanda Igwe @amandaigwe

About: Cloud Engineer | DevOps | Security | Linux | Automation

Joined:
Apr 7, 2025

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

Publish Date: May 15
4 0

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

Comments 0 total

    Add comment