The tar utility (tar
is short for tape archive) allows you to compress files and directories into a single file called a tarball. Note that compressing, listing, and extracting all use the same command (tar), but the options used differ depending on which action you wish to perform.
Like with all commands, you can find more information by checking man tar
, but since the version of tar used on Linux is a GNU product, you can also find information by typing info tar
.
Table 3.4. Commands for handling compressed files (tarballs)[30]
Command | Action |
---|---|
| Creates a tarball called foo.tar.gz from the list of files and directories (separated by spaces) in file_list |
| Lists the files and directories in foo.tar.gz (does not extract them) |
| Extracts the contents of foo.tar.gz and places them in the current directory |
[30] Although, when used with the options above, tar will be silent (that is, it won't provide any message to the user unless there's a problem, as mentioned in Section 1.5, “Key differences between Windows/Mac OS X and Linux”), you can use the |
[29] Joe Barr, CLI for Noobies: A Primer on the Linux Command Line (Boston: Prentice Hall, 2008), 151-155.