Skip to content
Advertisement

Why does tar -c command remove leading `/’ from member names

Looking to find the practical reasons the command tar -c /filea > /fileb gives the following output: tar:Removing_leading / from member names.

I have researched it quite a bit but only come across very vague reasons such as protects against some sort of attack etc. The majority just give explanations on a workaround should you want it.

I do not want a workaround. I am simply curious as to the actual practical reasons for it happening. Any help would be appreciated.

Advertisement

Answer

This helps avoid mistakes which could cause important files to be overwritten. Files are normally extracted relative to the current working directory of the tar command.

Just Example:

If you archive /etc/httpd this directory it removes leading /. Because. If it exists after extract current /etc/httpd will overwrite with archive /etc/httpd.

After removing the leading ‘/’ it extract on your working directory. If you extract on /var/tmp directory it will kept as /var/tmp/etc/httpd

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement