tar: cannot change ownership to uid ***, gid ***: Operation not permitted

参考链接:
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/[..]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值