我需要将 tar 文件的所有者及其内容设置为当前用户。
我将在文件夹中接收来自用户 FOO 的文件config_files/billing/xml/incommingBills 每当 tar 文件复制到此位置时,我想将所有者设置为当前用户,即 BAR。还希望将 tar 文件的内容设置为 BAR。
答案1
如果您要处理tar
文件本身,则文件所有者或 root 用户必须chown newusername /path/to/file
.或者,如果您具有超级用户访问权限,则可以sudo chown $(whoami) /path/to/file
。
如果您谈论的是包含的所有权信息之内该tar
文件,我将遵循手册:
-o (x mode) Use the user and group of the user running the program rather than those specified in the archive. Note that this has no significance unless -p is specified, and the program is being run by the root user. In this case,
the file modes and flags from the archive will be restored, but ACLs or owner information in the archive will be discarded.