manpagez: man pages & more
info tar
Home | html | info | man
[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.3.1 Overriding File Metadata

As described above, a tar archive keeps, for each member it contains, its metadata, such as modification time, mode and ownership of the file. GNU tar allows to replace these data with other values when adding files to the archive. The options described in this section affect creation of archives of any type. For POSIX archives, see also Controlling Extended Header Keywords, for additional ways of controlling metadata, stored in the archive.

--mode=permissions

When adding files to an archive, tar will use permissions for the archive members, rather than the permissions from the files. permissions can be specified either as an octal number or as symbolic permissions, like with chmod (See File permissions in GNU file utilities. This reference also has useful information for those not being overly familiar with the UNIX permission system). Using latter syntax allows for more flexibility. For example, the value ‘a+rw’ adds read and write permissions for everybody, while retaining executable bits on directories or on any other file already marked as executable:

$ tar -c -f archive.tar --mode='a+rw' .
--mtime=date

When adding files to an archive, tar will use date as the modification time of members when creating archives, instead of their actual modification times. The argument date can be either a textual date representation in almost arbitrary format (see section Date input formats) or a name of an existing file, starting with ‘/’ or ‘.’. In the latter case, the modification time of that file will be used.

The following example will set the modification date to 00:00:00, January 1, 1970:

$ tar -c -f archive.tar --mtime='1970-01-01' .

When used with ‘--verbose’ (see section The ‘--verbose’ Option) GNU tar will try to convert the specified date back to its textual representation and compare it with the one given with ‘--mtime’ options. If the two dates differ, tar will print a warning saying what date it will use. This is to help user ensure he is using the right date.

For example:

$ tar -c -f archive.tar -v --mtime=yesterday .
tar: Option --mtime: Treating date 'yesterday' as 2006-06-20
13:06:29.152478
…
--owner=user

Specifies that tar should use user as the owner of members when creating archives, instead of the user associated with the source file.

If user contains a colon, it is taken to be of the form name:id where a nonempty name specifies the user name and a nonempty id specifies the decimal numeric user ID. If user does not contain a colon, it is taken to be a user number if it is one or more decimal digits; otherwise it is taken to be a user name.

If a name is given but no number, the number is inferred from the current host’s user database if possible, and the file’s user number is used otherwise. If a number is given but no name, the name is inferred from the number if possible, and an empty name is used otherwise. If both name and number are given, the user database is not consulted, and the name and number need not be valid on the current host.

There is no value indicating a missing number, and ‘0’ usually means root. Some people like to force ‘0’ as the value to offer in their distributions for the owner of files, because the root user is anonymous anyway, so that might as well be the owner of anonymous archives. For example:

$ tar -c -f archive.tar --owner=0 .

or:

$ tar -c -f archive.tar --owner=root .
--group=group

Files added to the tar archive will have a group ID of group, rather than the group from the source file. As with ‘--owner’, the argument group can be an existing group symbolic name, or a decimal numeric group ID, or name:id.


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

This document was generated on November 1, 2013 using texi2html 5.0.

© manpagez.com 2000-2024
Individual documents may contain additional copyright information.