@UNREVISED
By default, GNU tar
drops a leading `/' on input or output.
This option turns off this behavior; it is equivalent to changing to the
root directory before running tar
(except it also turns off the
usual warning message).
When tar
extracts archive members from an archive, it strips any
leading slashes (`/') from the member name. This causes absolute
member names in the archive to be treated as relative file names. This
allows you to have such members extracted wherever you want, instead of
being restricted to extracting the member in the exact directory named
in the archive. For example, if the archive member has the name
`/etc/passwd', tar
will extract it as if the name were
really `etc/passwd'.
Other tar
programs do not do this. As a result, if you create an
archive whose member names start with a slash, they will be difficult
for other people with a non-GNU tar
program to use. Therefore,
GNU tar
also strips leading slashes from member names when
putting members into the archive. For example, if you ask tar
to
add the file `/bin/ls' to an archive, it will do so, but the member
name will be `bin/ls'.
If you use the --absolute-names (-P) option, tar
will do
neither of these transformations.
To archive or extract files relative to the root directory, specify the --absolute-names (-P) option.
Normally, tar
acts on files relative to the working
directory--ignoring superior directory names when archiving, and
ignoring leading slashes when extracting.
When you specify --absolute-names (-P), tar
stores file names
including all superior directory names, and preserves leading slashes.
If you only invoked tar
from the root directory you would never
need the --absolute-names (-P) option, but using this option may be
more convenient than switching to root.
@FIXME{Should be an example in the tutorial/wizardry section using this to transfer files between systems.}
@FIXME{Is write access an issue?}
@FIXME{this is still horrible; need to talk with dan on monday.}
tar
prints out a message about removing the `/' from file
names. This message appears once per GNU tar
invocation. It
represents something which ought to be told; ignoring what it means can
cause very serious surprises, later.
Some people, nevertheless, do not want to see this message. Wanting to
play really dangerously, one may of course redirect tar
standard
error to the sink. For example, under sh
:
$ tar -c -f archive.tar /home 2> /dev/null
Another solution, both nicer and simpler, would be to change to the `/' directory first, and then avoid absolute notation. For example:
$ (cd / && tar -c -f archive.tar home) $ tar -c -f archive.tar -C / home
Go to the first, previous, next, last section, table of contents.