How to TAR

List of most useful tar commands

Create archive archive.tar containing files file1 and file2:
tar -cf archive.tar file1 file2 # add -z to compress

List the files in the archive archive.tar verbosely:
tar -tvf archive.tar

Extract the files from archive archive.tar:
tar -xf archive.tar

Extract the files from gzipped archive archive.tar.gz verbosely:
tar -xzvf archive.tar.gz

Untar files in specified directory:
tar -xvf file.tar -C /home/your/foler/

Create a tar gzipped archive from folder dirname/
tar cvzf archive_name.tar.gz dirname/

Append file1 to file.tar :
tar -rf file.tar file1

Split a tarball into multiple parts of particular size:
tar cf - <dir> | split -b <max_size>M - <name>.tar. 
# for example:
tar cf - file_to_archive | split -b 500m - archive_name.tar. # will split file into chunks of 500Mb

Rejoin later with:
cat *.tar.* | tar xf -

Posted: 4.16.2014