Gzip is actually a file format which is a compressed file. There is also a tool named gzip which is used to compress and decompress files. Gzip is developed in 1992. It use DEFLATE algorithm with LZ77 and Huffman coding.
$ gzip -h
Gzip can only compress file. It cannot compress multiple files folder or folders. Gzip command is generally used with
tar command. We will only provide the file to be compressed. In this example we will compress
thefile.txt . The output file name will be the same with just adding
$ gzip thefile.txt
List Compressed File Contents
Compressed file contents can be listed without uncompressing them. We will use
-l option. In the example we want to list
thefile.txt.gz compressed file settings. There is also information about compressed size, file ratio, uncompressed_name etc.
$ gzip -l thefile.txt.gz
Higher Compression Rate
There are levels those are used to set compression ration, compressed file size and compression duration. Higher level compression will need more compression time but generally creates less file size. This is a trade off. We will use
--best options to specify.
$ gzip -9 thefile.txt
Another option for compression is faster compression. Actually thie is reverse of the higher compression rate. Compression duration will be less but the size will be higher than default compression rate. We will use
$ gzip --fast thefile.txt
Files can be decompressed with
gunzip command or with
-d parameter. gunzip is actually the alias of
gzip -d .
$ gzip -d thefile.txt.gz