参考链接:
cannot change ownership to uid ***, gid ***
Linux tar: Cannot change ownership to […]: Permission denied
tar命令解压时,出现 cannot change ownership to uid ***, gid ***
解决办法:
使用tar命令的 --no-same-permissions 参数选项或者 尝试 --no-same-owner options 参数选项
tar --no-same-owner -xzf XX.tar.gz
————————————————
版权声明:本文为CSDN博主「mxdxm8899」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/mxdxm8899/article/details/84606302
In a script I was working on, the tar command always reported the following error when I tried to extract an archive:
Cannot change ownership to uid 1000 , gid 1000: Permission denied
But I was executing the script as root! The reason for this error to occur turned out to be relatively simple. Hint: It has to do with CIFS.
The command in the script looked something like this:
tar xzf $INPUT_FOLDER/archive.tar.gz -C /mnt/test-nas/[..]
So tar tried to extract the contents of the archive to /mnt/test-nas/[…] and failed (even as root). It turns out that tar tries to preserve the file permissions when run as root:
-p, --preserve-permissions, --same-permissions
extract information about file permissions (default for superuser)
Since the filesystem /mnt/test-nas/ was mounted via SMB, even root had trouble setting the correct permissions and therefore failed. You can get around this problem by specifying --no-same-owner, so tar won’t try to set an owner:
tar xzf $INPUT_FOLDER/archive.tar.gz --no-same-owner -C /mnt/test-nas/[..]