
How to Extract a .gz File or directory in Linux using command prompt / terminal / shell / bash
Extract GZ archive file in Linux Terminal
To extract the GZ archive to the current directory, use below command.
$ gunzip archive.gz
.gz files are compressed with gzip compression algorithm. To extract .gz files we use gunzip command is used in Linux.
if the operation is successful, nothing is shown and linux command prompt is given back to the user.
Extract GZ file and see verbose output
if you want to see what happens during the unzip operation , you can user the -v parameter with the command.
# gunzip -v file_name.gz
-v stands for verbose, which shows a log of actions happening while the archive is decompressed.
Also note, after decompressing using gubzip , the GZ extention is removed from the file. so , your compressed archive is no longer available but the extracted file.
Compress a directory using gzip
On Linux, gzip is unable to compress a folder, it used to compress a single file only. To compress a folder, you should use tar + gzip, which is tar -z.
tar -zcvf outputFileName.tar.gz folderToCompress