Unzip .gz File in Linux
gzipCommand to Compress a File in Linux
gzipCommand to Decompress a File in Linux
gunzipCommand to Decompress a File in Linux
tarCommand to Extract
.tar.gzFiles in Linux
A GZ file is an archive file that has been compressed using the GNU zip (gzip) compression algorithm. It usually contains a single compressed file, but it can also hold multiple compressed files. The
gzip command is primarily used for file compression on Unix operating systems.
gzip Command to Compress a File in Linux
The command above compresses the file without keeping the original. We can use the following command to keep the original file as well.
gzip < filename > filename.gz
We can also maintain the original file by using the
gzip -k filename
gzip Command to Decompress a File in Linux
We can use the
-d option with
gzip command to decompress the
.gz compressed files.
gzip -d filename.gz
Same as in the compression, we can use the
-k option to keep the original compressed file and decompress it.
gzip -d -k filename.gz
gunzip Command to Decompress a File in Linux
We can also unzip the
.gz file using
gunzip command. To decompress using the file using
gunzip, use the following command.
And to keep the compressed file.
gunzip -k filename.gz
tar Command to Extract
.tar.gz Files in Linux
The files with the suffix
.tar.gz are just Gzip compressed
.tar archives files. We can extract these kinds of files using the following command.
tar -xf filename.tar.gz
The archive will be extracted in the current working directory after the
tar command automatically identifies the compression type.