Linux 为什么 tar 不保留文件权限?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20338215/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
why doesn't tar preserve file permissions?
提问by Andres Gonzalez
I have noticed that a tarball created on one linux does not preserve the file permissions when extracted on another linux.
我注意到在一个 linux 上创建的 tarball 在另一个 linux 上解压缩时不会保留文件权限。
How can I make tar preserve the file permissions?
如何让 tar 保留文件权限?
采纳答案by Robin Green
Use the p
option, both when creating the tarball and when extracting it.
p
在创建 tarball 和提取它时都使用该选项。
回答by Pippin
回答by rralf
Having a short look at the manpage clarifies your issue:
看一下联机帮助页可以澄清您的问题:
-p, --preserve-permissions, --same-permissions
extract information about file permissions (default for superuser)
But mind, that untaring your archive on some filesystems like FAT won't preserve permissions as they don't support it.
但请注意,在某些文件系统(如 FAT)上解压缩存档不会保留权限,因为它们不支持它。
Also the numeric owner / access time preserve might be intersting to you:
此外,数字所有者/访问时间保留可能对您感兴趣:
--numeric-owner
always use numbers for user/group names
--atime-preserve
preserve access times on dumped files, either by restoring the
times