tar: Removing leading `/' from member names
[email protected] # tar fcz bkup.tar.gz /home/foo/ tar: Removing leading `/' from member names
How can I solve this problem and keep the
/on file names ?
What exactly is not working as expected?
-Poption to disable this feature.
tar fczP bkup.tar.gz /home/foo/ tar fcz bkup.tar.gz --absolute-names /home/foo
This is the correct answer, but be aware, that **in most cases, this is not what you want**, cause it results in an archive that extracts in complete paths!
Using the `-C /` option as described in @Marcus' answer will git rid of the STDERR message if that is your primary goal.
As @rubo77 commented, usually this is not the expected result of the command.
Most of the time this is not what a user wants, simply because most of them don't read the manual until they need to (ain't nobody got time for that). So, it would be wise to, at least, expand your answer, warning people not to do this unless they are absolutely sure they understand what's the effect of it. Especially being accepted as an answer.
@MladenB. `tar` also removes the leading slash by default when extracting. So even if you use this option when creating the archive, it won't be a problem unless the user also uses it when extracting.
great, why not give an example though? where do these commands go? at the end? the beginning? in between?
Archives with absolute locations are a security risk. Attackers could use such archives to trick users into installing files in critical system locations.
@A.B. That assumes you're making the archive for public distribution. If you're doing it for an internal backup, it's not as much of a concern.