DevOps Essentials

View on GitHub



tar – manipulate tape archives


tar [bundled-flags ] [ | ...]

tar {-c} [options] [files directories]
tar {-r -u} -f archive-file [options] [files directories]
tar {-t -x} [options] [patterns]


tar creates and manipulates streaming archive files. This implementation can extract from tar, pax, cpio, zip, jar, ar, and ISO 9660 cdrom images and can create tar, pax, cpio, ar, and shar archives.

The first synopsis form shows a ``bundled’’ option word. This usage is provided for compatibility with historical implementations.

The other synopsis forms show the preferred usage. The first option to tar is a mode indicator from the following list:

In -c, -r, or -u mode, each specified file or directory is added to the archive in the order specified on the command line. By default, the contents of each directory are also archived.

In extract or list mode, the entire command line is read and parsed before the archive is opened. The pathnames or patterns on the command line indicate which items in the archive should be processed.



Consider the following example

$ tar -cvf file.tar file1 file2 file3