linux Unzipping gz File cli

Unzipping gz File

On Linux and macOS, you can decompress a .gz file using the gzip utility. The syntax is as follows:

gzip -d file.gz

The command will restore the compressed file to its original state and remove the .gz file.

To keep the compressed file pass the -k option to the command:

gzip -dk file.gz

Another command that you can use to decompress a .gz file is gunzip This command is basically an alias to file with gzip -d.

To open a .gz file with gunzip simply pass the file name to the command:

gunzip file.gz

If you’re on a desktop environment and the command-line is not your thing, you can use your File manager. To open (unzip) a .gz file, right-click on the file you want to decompress and select “Extract”.

Windows users need to install additional software such as 7zip to open .gz files.

Extracting tar.gz File

Gzip algorithm is designed to compress only a single file. Files that end in .tar.gz are .tar archives compressed with gzip.

To extract a tar.gz file , use tar command with the -xf options followed by the compressed archive name:

tar -xf archive.tar.gz

The command will auto-detect the compression type and will extract the archive in the