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:
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 gzip
command in Linux. The gzip
command offers additional options for advanced compression settings, including compression level adjustments.