tar: absolute

1 
1 6.10.2 Absolute File Names
1 --------------------------
1 
1 By default, GNU 'tar' drops a leading '/' on input or output, and
1 complains about file names containing a '..' component.  There is an
1 option that turns off this behavior:
1 
1 '--absolute-names'
1 '-P'
1      Do not strip leading slashes from file names, and permit file names
1      containing a '..' file name component.
1 
1    When 'tar' extracts archive members from an archive, it strips any
1 leading slashes ('/') from the member name.  This causes absolute member
1 names in the archive to be treated as relative file names.  This allows
1 you to have such members extracted wherever you want, instead of being
1 restricted to extracting the member in the exact directory named in the
1 archive.  For example, if the archive member has the name '/etc/passwd',
1 'tar' will extract it as if the name were really 'etc/passwd'.
1 
1    File names containing '..' can cause problems when extracting, so
1 'tar' normally warns you about such files when creating an archive, and
1 rejects attempts to extracts such files.
1 
1    Other 'tar' programs do not do this.  As a result, if you create an
1 archive whose member names start with a slash, they will be difficult
1 for other people with a non-GNU 'tar' program to use.  Therefore, GNU
1 'tar' also strips leading slashes from member names when putting members
1 into the archive.  For example, if you ask 'tar' to add the file
1 '/bin/ls' to an archive, it will do so, but the member name will be
1 'bin/ls'(1).
1 
1    Symbolic links containing '..' or leading '/' can also cause problems
1 when extracting, so 'tar' normally extracts them last; it may create
1 empty files as placeholders during extraction.
1 
1    If you use the '--absolute-names' ('-P') option, 'tar' will do none
1 of these transformations.
1 
1    To archive or extract files relative to the root directory, specify
1 the '--absolute-names' ('-P') option.
1 
1    Normally, 'tar' acts on files relative to the working
1 directory--ignoring superior directory names when archiving, and
1 ignoring leading slashes when extracting.
1 
1    When you specify '--absolute-names' ('-P'), 'tar' stores file names
1 including all superior directory names, and preserves leading slashes.
1 If you only invoked 'tar' from the root directory you would never need
1 the '--absolute-names' option, but using this option may be more
1 convenient than switching to root.
1 
1 '--absolute-names'
1      Preserves full file names (including superior directory names) when
1      archiving and extracting files.
1 
1    'tar' prints out a message about removing the '/' from file names.
1 This message appears once per GNU 'tar' invocation.  It represents
1 something which ought to be told; ignoring what it means can cause very
1 serious surprises, later.
1 
1    Some people, nevertheless, do not want to see this message.  Wanting
1 to play really dangerously, one may of course redirect 'tar' standard
1 error to the sink.  For example, under 'sh':
1 
1      $ tar -c -f archive.tar /home 2> /dev/null
1 
1 Another solution, both nicer and simpler, would be to change to the '/'
1 directory first, and then avoid absolute notation.  For example:
1 
1      $ tar -c -f archive.tar -C / home
1 
1    ⇒Integrity, for some of the security-related implications of
1 using this option.
1 
1    ---------- Footnotes ----------
1 
1    (1) A side effect of this is that when '--create' is used with
1 '--verbose' the resulting output is not, generally speaking, the same as
1 the one you'd get running 'tar --list' command.  This may be important
11 if you use some scripts for comparing both outputs.  ⇒listing
 member and file names, for the information on how to handle this case.
1