List of various tar commands for your daily uses.

  1. Create an (uncompressed) archive.
  • Create: tar cvf data.tar data/
  • Extract: tar xvf data.tar

2. Create and compress in xz format

Note: xz = LZMA = Lempel–Ziv–Markov chain algorithm

  • Create: tar Jcvf data.tar.xz data/
  • Extract: tar xvf data.tar.xz

3. Create and compress in gzip format

  • Create: tar zcvf data.tar.gz data/
  • Extract: tar xvf data.tar.gz

4. Create and compress in bzip2 format

  • Create: tar jcvf data.tar.bz2 data/
  • Extract: tar xvf data.tar.bz2

5. Create and compress in zip format

  • Create: zip -r data/
  • Extract: unzip
  • Extract to a directory: unzip -d data/
  • Create with password: zip -P <password> -r data/
  • Unzip with password: unzip -P <password>

6. To encrypt/decrypt a (tarred) file with openssl

Refer to this post.