Next: , Up: create options


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 PAX 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 Permissions. 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 Date input formats) or a name of the 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 UTC, January 1, 1970:

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

When used with --verbose (see verbose tutorial) 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. The argument user can be either an existing user symbolic name, or a decimal numeric user ID.

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. The argument group can be either an existing group symbolic name, or a decimal numeric group ID.