TAR

The tar command creates and manipulates streaming archive files.

Create an uncompressed tar archive

tar cvf ARCHIVE.tar DIRECTORY
  • c - Create a new archive
  • v - Verbosely list files
  • f - Follow archive file name

Create a tar gzipped archive

tar cvfz ARCHIVE.tar.gz DIRECTORY
  • z - Filter the archive through gzip

Create a bzipped (bzip2) tar archive

tar cvfj ARCHIVE.tar.bz2 DIRECTORY
  • j - Filter the archive through bzip2

N.B. bzip2 takes more time to compress and decompress than gzip but requires less space.


Extract a .tar archive

tar xvf ARCHIVE.tar
  • x - Extract files from archive

Extract a gzipped | bzipped tar archive

tar xvfz ARCHIVE.tar.gz
tar xvfj ARCHIVE.tar.bz2

List the contents of an archive

tar tvf ARCHIVE.tar
tar tvfz ARCHIVE.tar.gz
tar tvfj ARCHIVE.tar.bz2

Extract a single file or directory

tar xvf ARCHIVE.tar <PATH>

Append a file or directory to an existing archive

tar rvf ARCHIVE.tar <PATH>
  • r - Append files to the end of an archive