How To Unzip tar.gz File?
Compression provides more disk space and network efficiency in IT systems. There are different type, level and performance compression algorithms.
tar.gz is de facto standard for Linux systems for a long time. In this tutorial we will look different ways to unzip or uncompres
Unzip with tar
tar is our old friend which can provide compress and decompress of a lot of different compression formats. We will unzip
test.tar.gz in this example with
xis used to extract
vis used for verbose mode
fis used for file mode
$ tar xvf test.tar.gz
Unzip with gunzip
gunzip is the unzip command provided by
gzip suite. We can use this command without any option in order to unzip. But in this example we use
-voption which is used for verbose mode.
$ gunzip -v test.tar.gz
Unzip with 7z
7z is my favouritte compression algorithm and tool. It supports a lot of formats from zip to rar.
gz format is also supported. We can provide
e option in order to extract the
7z automatically detects the format.
$ 7z e test.tar.gz
List tar.gz Contents
If we want to unzip only some of files from a
tar.gz archive first we need to list files. We can list files different ways but we will look only single command which is
$ tar tvf test.tar.gz
Unzip Only Specified Directory
If we need to extract only some of files or directories we need to specify them. We will use unzip command and provide the files and directories at the end of command we want to extract. In this example we will extract file
oldbackup/db.conf file from
$ tar xvf test.tar.gz oldbackup/db.conf