To extract a tar file
tar -xvf file.tar
To extract a tar.gz file
tar -xvfz file.tar.gz
To extract a tar.bz2 file
tar -xvfj file.tar.bz2
The flags explained as follows:
- -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).