Home > Linux > Linux tar, gz and bz2

Linux tar, gz and bz2

  • t: List the contents of an archive
  • v: Verbosely list files processed (display detailed information)
  • z: Filter the archive through gzip so that we can open compressed (decompress) .gz tar file
  • j: Filter archive through bzip2, use to decompress .bz2 files.
  • f: File. Use the tar file argument as the name of the tar file
  • x: Extract or restore
  • c: Create


tar -tvf file.tar : list the contents of the tar file 
tar -xvwf myfile.tar : extract all files from the tar 
tar xvf test.tar testfile1.bz2 : extract only the file called testfile1.bz2 from a tar archive
tar -cvwf txtfiles.tar *.txt : create a tar of all .txt files, name the tar file txtfiles.tar and put it in the current dir

bz2 ( bunzip2 )

tar -jtvf file.tar.bz2 : list the contents of the tar.bz2 file
tar -xvjpf filename.tar.bz2 : unzip a file compressed with .tar.bz2 
bzip2 filename.txt : compress a file with bunzip2 
bunzip2 filename.bz2 : unzip a file compressed only with bz2

gzip ( gunzip )

tar -ztvf file.tar.gz : list the contents of the tar.gz file
gzip filename.txt : compress a file using gunzip
gunzip filename.txt.gz : uncompress a file using gunzip
Categories: Linux
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: