Linux has many commands line tools to compress/decompress files and gzip is one of them. In this article, we will show you the basics of gzip and how to use it with some examples.
Example - 1 Compress file with gzip
You can use the below command to compress the file with gzip.
gzip [file-name]
You can see now in the below images that we have used gzip command to compress file samplefile.txt and it is compressed now in samplefile.txt.gz
Example - 2 How to uncompress the file using gzip
You can use the below command to uncompress the file with gzip. Use the -d syntex to do it.
gzip -d [compressed-file-name]
You can see now in the below images, We have uncompressed the file samplefile.txt.gz. And the compressed file was deleted.