Extract (Unzip)

tar

tar is “Tape ARchive”.

Gzip Command in Linux

Gzip is one of the most popular compression algorithms that allow you to reduce the size of a file and keep the original file mode, ownership, and timestamp.

gzip Command Syntax

  • Gzip compresses only single files and creates a compressed file for each given file. By convention, the name of a file compressed with Gzip should end with either .gz or .z.

  • If you want to compress multiple files or directory into one file, first you need to create a Tar archive and then compress the .tar file with Gzip. A file that ends in .tar.gz or .tgz is a Tar archive compressed with Gzip.

Compressing Files with gzip

To compress a single file invoke the gzip command followed by the filename:

gzip filename

gzip will create a file filename.gz and delete the original file.

By default, gzip keeps the original file timestamp, mode, ownership, and name in the compressed file. Keep the original file

If you want to keep the input (original) file, use the -k option:

gzip -k filename

Another option to keep the original file is to use the -c option which tells gzip to write on standard output and redirect the output to a file:

gzip -c filename > filename.gz

Verbose output

gzip -v filename

Compress multiple files

gzip file1 file2 file3

Next