| • Science | • People | • Locations | • Timeline |
| Contents | ||
tar and were standardized by POSIX.1-1998 and later POSIX.1-2001. It is used widely to archive and unarchive files, which means to accumulate a large collection of files into a single archive file (packer), while preserving file system information such as user and group permissions, dates, and directory structures. In the Unix tradition of "one job, one program", it does not support compression directly.tar was originally developed for use with sequential access devices such as tape drives, specifically for backup purposes. Somewhere along the line the -f argument was added and tar is now more frequently used as a general archive utility. tar's linear roots can still be seen in its slow partial extraction performance, when it has to read through the whole archive to extract only the final file. Commonly a tar file is referred to as a tarball.
tar is most commonly used in tandem with an external compression utility such as gzip, bzip2 or, formerly, compress, since it has no built in data compression facilities. These compression utilities generally only compress a single file, hence the pairing with tar, which can produce a single file from many files. One might think this requires more steps, but it is possible to use the Unix pipeIn the context of Unix and Unix-like operating systems, as well as MS-DOS, a pipe signifies that the output of one program (" stdout") feeds directly as input (" stdin") to another program. Any error messages from the first program (" stderr") are not pas capability to combine the two steps manually. Also, the GNUFor the African animal gnu see wildebeest. logo Believed to be the original artwork of Etienne Suvasa GNU is a recursive acronym for "GNU's Not Unix". The GNU project was launched in 1983 by Richard Stallman with the goal of creating a complete operating version of tar supports the command line options -z (gzip), -j (bzip2), and -Z (compress), which will compress the archive file it creates.
tar -cf packed_files.tar file_to_pack1 file_to_pack2 ...
tar -cf packed_files.tar file_to_pack1 file_to_pack2 ...
gzip packed_files.tar
tar -cf - file_to_pack1 file_to_pack2 ... | gzip -c > packed_files.tar.gz
tar -xf file_to_unpack.tar
gunzip packed_files.tar.gz
tar -xf packed_files.tar
gunzip -c packed_files.tar.gz | tar -xf -
To use bzip2 instead of gzip, simply replace the commands above with bzip2 where gzip is used and bunzip2 where gunzip is used.
Using GNUFor the African animal gnu see wildebeest. logo Believed to be the original artwork of Etienne Suvasa GNU is a recursive acronym for "GNU's Not Unix". The GNU project was launched in 1983 by Richard Stallman with the goal of creating a complete operating tar's compression flag feature:
tar -czf packed_files.tgz file_to_pack1 file_to_pack2 ...
tar -cjf packed_files.tbz2 file_to_pack1 file_to_pack2 ...
tar -cZf packed_files.tar.Z file_to_pack1 file_to_pack2 ...
tar --use-compress-program=name_of_program -cf packed_files.tar.XXX file_to_pack1 file_to_pack2 ...
tar -xzf file_to_unpack.tar.gz
tar -xjf file_to_unpack.tar.bz2
tar -xZf file_to_unpack.tar.Z
tar --use-compress-program=name_of_program -xf file_to_unpack.tar.XXX