TAR Archiver
From Jonsdocswiki
TAR is a popular archive format on the Linux / Unix platform. Contrary to misconception, TAR does not compress data but merely lumps it together as one file (an archive).
Contents |
Common file extensions
- .tar - standard TAR archive
- .tar.gz - a GZipped TAR archive
- Also .tgz
- .tar.bz2 - a BZipped2 TAR archive
GZip/ Bzip2
GZip and Bzip2 are compression utilities.
Creating a TAR archive
tar -cpvf ARCHIVE.tar /location/of/files
After the "-" are the command arguments:
- c : create archive
- p : preserve permissions
- v : be verbose, show what is being done
- r : Recurse into sub-directories
- f : file (i.e. not tape)
The same command could be written as follows but the above convention is more usual:
tar -c -p -v -f ARCHIVE.tar /location/of/files
Common problems creating archives
- The f argument must be the last argument specified, right before the file name.
Creating a .tar.bz2
While you could create a TAR archive and then manually pass it to BZip2 for compression, TAR does give the option of doing this in a single command:
tar -cjpvf ARCHIVE.tar /location/of/files
New arguments:
- j : Pass to Bzip2 for compression.
Extracting a TAR archive
tar -xvpf ARCHIVE.tar /location/of/files
New arguments:
- x : Extract
