why doesn't tar preserve file permissions? [closed]

随声附和 提交于 2019-12-04 19:13:13

问题


I have noticed that a tarball created on one linux does not preserve the file permissions when extracted on another linux.

How can I make tar preserve the file permissions?


回答1:


Use the p option, both when creating the tarball and when extracting it.




回答2:


Can you try:

tar -pcvzf xxx.tar.gz

p == preserve permissions
c == create archive
v == verbose (print names while making tar)
z == gzip
f == tar file name

Source




回答3:


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.

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


来源:https://stackoverflow.com/questions/20338215/why-doesnt-tar-preserve-file-permissions

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!