Extract tar file in Linux

How to extract a compressed folder or file usually it calls as a tarball?

Tarball is a computer file format that can combine multiple files into a single file called ‘tarball’, usually compressed.

Extract or Unpack a TarBall

To extract a tar file, type:

tar -xvf yourfile.tar

To extract a .tar.gz (gzip)file. Gzip is more advanced compression, as you can save more space/bandwidth with gzip files. Note the z options

tar -xzvf yourfile.tar.gz

To extract a .tar.bz2 (bzip2) file, enter (note -j option):

tar -xjvf yourfile.tar.bz2

Codes Explained

  • -x : Extract a tar ball.
  • -v : Verbose output or showing progress while extracting files.
  • -f : Specify an archive or a tarball filename.
  • -z : Extract the contents of the compressed file created by gzip program (tar.gz extension).
  • -j : Extract the contents of the compressed file created by bzip2 program (tar.bz2 extension).

Output would be like

Extract tar file in Linux

Editorial Staff
 

Editorial Staff at tutsplanet is a dedicated team to write various tutorial articles.