How to decompress a compressed tar archive in Linux?
Published on Aug. 22, 2023, 12:17 p.m.
To decompress a compressed tar archive in Linux, you can use the tar
command with the appropriate options depending on the compression format. Here are some examples:
To decompress a tar.gz or .tgz file, use the -z
option to enable gzip compression/decompression:
tar -xzvf archive.tar.gz
To decompress a tar.bz2 file, use the -j
option to enable bzip2 compression/decompression:
tar -xjvf archive.tar.bz2
To decompress a tar.xz file, use the -J
option to enable xz compression/decompression:
tar -xJvf archive.tar.xz
In each of these examples, x
tells tar
to extract files from the archive, v
is for verbose mode, f
specifies the filename of the archive, and the appropriate compression option is used (-z
for gzip, -j
for bzip2, and -J
for xz).
Note that the tar
command can also be used to create tar archives, in addition to extracting files from them. Also, depending on the distribution of Linux you’re using, tar
may be installed by default, or you may need to install it using your package manager.