Tar
From GNU's Tar Page:
- "The
Tarprogram provides the ability to create tar archives, as well as various other kinds of manipulation. For example, you can use Tar on previously created archives to extract files, to store additional files, or to update or list files which were already stored."
As an early Unix compression format, tar files (known as tarballs) are widely used for packaging in Unix-like operating systems. Both pacman and AUR packages are tarballs, and Arch uses GNU's Tar program by default.
Usage
For tar archives, tar by default will extract the file according to its extension:
$ tar xvf file.EXTENSION
Forcing a given format:
| File Type | Extraction Command |
|---|---|
file.tar |
tar xvf file.tar
|
file.tgz |
tar xvzf file.tgz
|
file.tar.gz |
tar xvzf file.tar.gz
|
file.tar.bz |
bzip -cd file.bz | tar xvf -
|
file.tar.bz2 |
tar xvjf file.tar.bz2bzip2 -cd file.bz2 | tar xvf -
|
file.tar.xz |
tar xvJf file.tar.xz xz -cd file.xz | tar xvf -
|
The construction of some of these tar arguments may be considered legacy, but they are still useful when performing specific operations. The Compatibility section of tar's man page shows how they work in detail.
Creating an archive and updating
Creating an initial archive and updating it proves useful for updating web-domains. First, create an archive in the present working directory. Note that tar will not include ./archive.tar into the new tarball if ./archive.tar already exists.
$ tar -cf ./archive.tar .
When updating the archive, keep in mind that tar will only update files listed in the archive.
$ tar --list -f ./archive.tar $ tar -uf ./archive.tar
See also
- GNU tar manual (Also available via
info tar)