Cheatsheet for unpacking tar archives.
For unpacking tar-archives through a command-line utility is used tar.
It is useful to know that archives tar have the file extension .tar Also in Linux, archives are widespread that have additional compression by other programs. For example, archives .tar.bz2 , .tar.gz and others. All of these archives can be unpacked using the utility tar.
To unpack the archive in format .tar into the current directory, run the command:
tar xvf archive.tar
Unpack tar.bz2, tar.bzip2, tbz2, tb2, tbz
tar xvjf archive.tar.bz2
Packaging tar.xz, txz
tar xvJf archive.tar.xz
Unpack tar.gz, tgz
tar xvzf archive.tar.gz
tar --lzma -xvf archive.tar.lzma
Explanation of options
x – unpack the archive.
v – Verbose-mode (display additional information during unpacking).
f – unpack the archive from a file.
j – call bzip2 to unpack the archive.
z – invoke gzip
J – call xz
How to uninstall applications in GNU / Linux
Unpacking to a specific directory
To unpack the archive into a specific directory, use the option -C or –directory, for example:
tar xvf archive.tar -C /to/directory
Note: the directory must exist.
We have covered a basic set of commands that can be used to unpack various kinds of tar archives. There are also some other types of archives, but they are less common.
Leave a Reply