[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.2 Using tar Options

GNU tar has a total of eight operating modes which allow you to perform a variety of tasks. You are required to choose one operating mode each time you employ the tar program by specifying one, and only one operation as an argument to the tar command (the corresponding options may be found at The Three Most Frequently Used Operations and The Five Advanced tar Operations). Depending on circumstances, you may also wish to customize how the chosen operating mode behaves. For example, you may wish to change the way the output looks, or the format of the files that you wish to archive may require you to do something special in order to make the archive look right.

You can customize and control tar’s performance by running tar with one or more options (such as ‘--verbose’ (‘-v’), which we used in the tutorial). As we said in the tutorial, options are arguments to tar which are (as their name suggests) optional. Depending on the operating mode, you may specify one or more options. Different options will have different effects, but in general they all change details of the operation, such as archive format, archive name, or level of user interaction. Some options make sense with all operating modes, while others are meaningful only with particular modes. You will likely use some options frequently, while you will only use others infrequently, or not at all. (A full list of options is available in see section All tar Options.)

The TAR_OPTIONS environment variable specifies default options to be placed in front of any explicit options. For example, if TAR_OPTIONS is ‘-v --unlink-first’, tar behaves as if the two options ‘-v’ and ‘--unlink-first’ had been specified before any explicit options. Option specifications are separated by whitespace. A backslash escapes the next character, so it can be used to specify an option containing whitespace or a backslash.

Note that tar options are case sensitive. For example, the options ‘-T’ and ‘-t’ are different; the first requires an argument for stating the name of a file providing a list of names, while the second does not require an argument and is another way to write ‘--list’ (‘-t’).

In addition to the eight operations, there are many options to tar, and three different styles for writing both: long (mnemonic) form, short form, and old style. These styles are discussed below. Both the options and the operations can be written in any of these three styles.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated on August 23, 2023 using texi2html 5.0.