Name
tar — stdin stdout - file -- opt --help --version
Synopsis
tar [options
] [files
]
The tar
program was
originally for backing up files onto a tape drive (its name is short
for “tape archive”). Although tape has lost its popularity, tar
is still the most common
file-packaging format for Linux. It can pack multiple files and
directories into a single file for transport, optionally
compressed.
$ tar -czvf myarchive.tar.gz mydir Create $ tar -tzvf myarchive.tar.gz List contents $ tar -xzvf myarchive.tar.gz Extract
If you actually have a tape drive, simply specify the drive’s device (such as /dev/tape) as the destination file:
$ tar -cf /dev/tape myfile1 myfile2
If you specify files on the command line, only those files are processed:
$ tar -xvf myarchive.tar file1 file2 file3
Otherwise, the entire archive is processed.
Useful options
|
Create an archive. You’ll have to list the input files and directories on the command line. |
|
Append files to an existing archive. |
|
Append new/changed files to an existing archive. |
|
Append one archive to
the end of another: e.g., |
|
List the archive. |
|
Extract files from the archive. |
|
Read the archive from, or write the archive to, the given file. This is usually a tar file on disk (such as myarchive.tar) but can also be a tape drive (such as /dev/tape). |
|
Diff (compare) the archive against the ... |
Get Linux Pocket Guide, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.