unzip file tar code example

Example 1: tar unpack

tar -xzf packed.tar.gz

Example 2: how to unzip Tar file

## Untar files in Current Directory ##
tar -xvf filename.tar.gz

## Untar files in specified Directory ##
tar -xvf filename.tar.gz -C /path_name_for_unzip/

-x : extract
-C : specified directory
-v : Verbosely show the .tar file progress.
-f : filename of archive file

Example 3: how to unzip using tar

tar -xf archive.tar.gz

Example 4: unarchive tar acrhive

tar -xvf file.tar etc/resolv.conf
tar -xzvf file.tar.gz etc/resolv.conf
tar -xjvf file.tar.bz2 etc/resolv.conf

#Extract files into a specific folder
tar -xf archive.tar.gz -C /home/linuxize/files