gzip command in Linux with Examples

gzip is a software application used for file compression and decompression. It is a common way of compressing files in Linux.

The gzip command in Linux is used to compress files. It reduces the size of a file or a group of files and creates a compressed file with the extension .gz.

Here are a few examples of how to use the gzip command:

gzip command in Linux with Examples

The syntax gzip command

gzip [ -acdfhlLnNrtvV19 ] [-S suffix] [ name ...  ]

On the man page, the describes it

Gzip reduces the size of the named files using Lempel-Ziv coding (LZ77).

gzip command in Linux with Examples

Creating a compressed file

[huupv@DevopsRoles ~]$ gzip filename.txt

Decompress a File Using the gzip Command

[huupv@DevopsRoles ~]$ gzip -d filename.gz

Decompress multiple compressed files

gzip -d file1.gz file2.gz file3.gz

The following details about gzip command in Linux.

man gzip

Compress multiple files

gzip file1 file2 file3

Keep the original file after compression or decompression

gzip -k filename
gzip -dk filename.gz

The -k option is used to keep the original file after compression or decompression. When compressing a file, the original file will be retained, and a compressed file will be created with the .gz extension. Similarly, when decompressing a file, the original compressed file will be retained, and a decompressed file will be created without the .gz extension.

Conclusion

gzip command is a simple command in Linux. It is the most popular in-use terminal Linux for file compression and decompression. These are some examples of how to use the gzip command in Linux. The gzip command offers additional options for advanced compression settings, including compression level adjustments. Thank you for reading the DevopsRoles page!

,

About HuuPV

My name is Huu. I love technology and especially Devops Skill such as Docker, vagrant, git so forth. I likes open-sources. so I created DevopsRoles.com site to share the knowledge that I have learned. My Job: IT system administrator. Hobbies: summoners war game, gossip.
View all posts by HuuPV →

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.