Archiving with tar
The tar
command was written to archive files. It was originally designed to store data on tape, thus the name, Tape ARchive. Tar allows you to combine multiple files and directories into a single file while retaining the file attributes, such as owner and permissions. The file created by the tar
command is often referred to as a tarball. These recipes describe creating archives with tar
.
Getting ready
The tar
command comes by default with all Unix-like operating systems. It has a simple syntax and creates archives in a portable file format. It supports many arguments to fine-tune its behavior.
How to do it...
The tar
command creates, updates, examines, and unpacks archives.
- To create an archive file with tar:
$ tar -cf output.tar [SOURCES]
The c
option creates a new archive and the f
option tells tar the name of a file to use for the archive. The f option must be followed by a filename:
$ tar -cf archive.tar file1 file2 file3 folder1 ..
- The
-t
option lists the contents of an archive...