How to extract / uncompress tar gz file

Supposed you have a tar.gz file or tar.bz2 file, here is how you can extract them using the tar function.

Type at the command prompt. Make sure you have the ownership and permission of the file.

tar -xvzf file-1.0.tar.gz - to uncompress a gzip tar file (.tgz or .tar.gz)
tar -xvjf file-1.0.tar.bz2 - to uncompress a bzip2 tar file (.tbz or .tar.bz2)
tar -xvf file-1.0.tar - to uncompressed tar file (.tar)

x = extract. This indicates an extraction
v = verbose. The files with relative locations will be displayed.
z = gZip-ped or j = bzip2-zipped
f = from/to file

The files will be extracted in the current folder.

For more info type the following on your command line:

tar --help
(Visited 4,442 times, 1 visits today)

2 thoughts on “How to extract / uncompress tar gz file”

  1. Riley Walz says:

    You do need a “-” before xvzf, xvjf or xvf for this command to function properly.

    1. I dont need “-” on my Arch Linux. I’m not sure about other distros. I think Debian-based distro like Raspbian or Mint would require the “-” sign.

Comments are closed.