Extract or Unpack a TarBall File
To unpack or extract a tar file, type:tar -xvf file.tar
To save disk space and bandwidth over the network all files are saved using compression program such as gzip or bzip2. To extract / unpack a .tar.gz (gzip) file, enter (note -z option): tar -xzvf file.tar.gz
To extract / unpack a .tar.bz2 (bzip2) file, enter (note -j option):tar -xjvf file.tar.bz
Where,
Where,
- -x : Extract a tar ball.
- -v : Verbose output or show progress while extracting files.
- -f : Specify an archive or a tarball filename.
- -j : Decompress and extract the contents of the compressed archive created by bzip2 program (tar.bz2 extension).
- -z : Decompress and extract the contents of the compressed archive created by gzip program (tar.gz extension).
How Do I Extract A Single File Called foo.txt?
To extract a single file called foo.txt, enter:tar -xvf file.tar foo.txttar -xzvf file.tar.gz foo.txttar -xjvf file.tar.bz2 foo.txt
You can also specify path such as etc/resolv.conf, enter:tar -xvf file.tar etc/resolv.conftar -xzvf file.tar.gz etc/resolv.conftar -xjvf file.tar.bz2 etc/resolv.conf
How Do I Extract a Single Directory Called etc?
To extract a single directory called etc, enter:tar -xvf file.tar etctar -xzvf file.tar.gz etctar -xjvf file.tar.bz2 etc