Linux rsync主机文件-权限被拒绝

Linux rsync主机文件-权限被拒绝,linux,permissions,rsync,host,Linux,Permissions,Rsync,Host,我想将一台服务器的主机文件与其他几台服务器同步。我没有任何问题与snycing其他文件。 只有主机文件不工作。此外,错误消息也很奇怪: rsync: mkstemp "/etc/.hosts.NOmAJ8" failed: Permission denied (13) rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1183) [sender=3.1.0]

我想将一台服务器的主机文件与其他几台服务器同步。我没有任何问题与snycing其他文件。 只有主机文件不工作。此外,错误消息也很奇怪:

rsync: mkstemp "/etc/.hosts.NOmAJ8" failed: Permission denied (13)
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1183) [sender=3.1.0]
我使用的命令是

rsync -a /etc/hosts user@host:/etc/hosts

我自己解决了这个问题。 我是hosts文件的所有者,但不是/etc/文件夹的所有者。改变这个解决了我的问题