如何在cp
不更改目标文件权限的情况下使用该命令?例如:
cp /tmp/file /home/file
Run Code Online (Sandbox Code Playgroud)
我不想改变chown
和 chgrp
上/home/file
。
Lek*_*eyn 36
如果您只打开手册cp
...
接下来不会覆盖文件权限和所有权+组权:
cp --no-preserve=mode,ownership /tmp/file /home/file
Run Code Online (Sandbox Code Playgroud)
请注意,如果您想保留所有权和组权,则需要 root 权限。
手册摘录:
Run Code Online (Sandbox Code Playgroud)--preserve[=ATTR_LIST] preserve the specified attributes (default: mode,owner- ship,timestamps), if possible additional attributes: context, links, xattr, all