共计 493 个字符,预计需要花费 2 分钟才能阅读完成。
使用 - S 参数
The -S (stdin) option causes sudo to read the password from the standard input instead of the terminal device.
改变文件权限:
echo "password" | sudo -S netstat -tlnp
echo "123456" | sudo -S chmod 777 test
rsync 数据同步
第一种方式:
echo "123456" | sudo -S /usr/bin/rsync -vzrtopg --progress --delete --password-file=/etc/rsyncd.secrets root@192.168.10.100::home /home/vmail
第二种方式
sudo /usr/bin/rsync -vzrtopg --progress --delete --password-file=/etc/rsyncd.secrets root@192.168.10.100::home /home/vmail << EOF
123465
EOF
正文完
扫码赞助
