以root身份移动文件保留所有权linux

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18344551/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-07 00:37:10  来源:igfitidea点击:

Move file as root preserving ownership linux

linuxshellcommand-lineterminalcommand

提问by Rombus

OS: Debian. I want to be able to move files and folders around as root and from the command line without changing it's owner and group. Is this possible?

操作系统:Debian。我希望能够以 root 用户身份从命令行移动文件和文件夹,而无需更改其所有者和组。这可能吗?

采纳答案by Radu Toader

rsync :

同步:

 -A, --acls                  preserve ACLs (implies --perms)
 -X, --xattrs                preserve extended attributes
 -o, --owner                 preserve owner (super-user only)
 -g, --group                 preserve group
     --devices               preserve device files (super-user only)
     --specials              preserve special files

man rsync

同步

回答by dseiple

The mvcommand preserves ownership and time-stamps. For the cpcommand there are various command line options you can use. For example

mv命令保留所有权和时间戳。对于该cp命令,您可以使用各种命令行选项。例如

cp -p file1 file2

man cpwill display all the available options

man cp将显示所有可用选项