Skip to content

Instantly share code, notes, and snippets.

@sangeeths
Created January 25, 2014 12:13
Show Gist options
  • Save sangeeths/8615443 to your computer and use it in GitHub Desktop.
Save sangeeths/8615443 to your computer and use it in GitHub Desktop.
Frequently Used Commands - tar
Compose a tar file:
-------------------
tar -cvf file.tar dir1/
tar -zcvf file.tar.gz dir1/
tar -jcvf file.tar.bz2 dir1/
Extract a tar file:
-------------------
tar -xvf file.tar
tar -zxvf file.tar.gz
tar -jxvf file.tar.bz2
List the files inside the tar ball without extracting:
------------------------------------------------------
tar -tvf file.tar
tar -ztvf file.tar.gz
tar -jtvf file.tar.bz2
Command Options:
----------------
c: Compose
x: Extract
t: List the contents of an archive
v: Verbosely list files processed
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 filename: Use archive file called filename
Tips:
-----
-> Use ‘z’ while compressing/decompressing/listing the file with GZIP.
-> Use ‘j’ while compressing/decompressing/listing the file with BZIP2.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment