Linux command: gzip

Quick startgzipCommand to compress files

You can use a compression protocol called gzip to compress filesLZ77usegzipcommand.

This is the simplest usage:

gzip filename

This will compress the file and append a.gzExtension. The original file is deleted. To prevent this, you can use-cOption and use output redirection to write the output tofilename.gzfile:

gzip -c filename > filename.gz

This-cThe option specifies that the output will enter the standard output stream, while leaving the original file unchanged

Or you can use-kOptions:

gzip -k filename

There are various compression levels. The higher the degree of compression, the longer it takes to compress (and decompress). The level ranges from 1 (fastest, worst compression) to 9 (slowest, better compression), and the default value is 6.

you can use it-<NUMBER>Options:

gzip -1 filename

You can compress multiple files by listing them:

gzip filename1 filename2

you can use it-rOptions:

gzip -r a_folder

This-vOption to print compression percentage information. This is to combine it with-k(Reserved) Options:

gzipCan also be used to decompress files-dOptions:

gzip -d filename.gz

ThisgzipThis command can be used in Linux, macOS, WSL and wherever you have a UNIX environment

Download mine for freeLinux Command Manual

More cli tutorials: