简体   繁体   English

为何tar -c命令从成员名称中删除前导`/'

[英]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. 为了找到实际的原因,命令tar -c /filea > /fileb提供以下输出: 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. 任何帮助,将不胜感激。

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. 通常,相对于tar命令的当前工作目录提取文件。

Just Example: 只是示例:

If you archive /etc/httpd this directory it removes leading /. 如果将/ etc / httpd归档到此目录,它将删除前导/。 Because. 因为。 If it exists after extract current /etc/httpd will overwrite with archive /etc/httpd. 如果解压缩后存在,则当前/ etc / httpd将被归档文件/ 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 如果解压缩到/ var / tmp目录,它将保留为/ var / tmp / etc / httpd

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM