一、实验背景
nexus安装教程:
https://www.jianshu.com/p/b25496ecc521
nexus服务的运行用户是nexus,用nexus登录操作系统,只能查看服务状态,无法执行启停服务命令
$ systemctl status nexus
$ systemctl stop nexus
$ systemctl start nexus
二、添加权限,使得nexus用户不用root密码执行nexus服务的启停
# vim /etc/sudoers
nexus ALL=(ALL) NOPASSWD: /bin/systemctl stop nexus, /bin/systemctl start nexus, /bin/systemctl status nexus
$ sudo /bin/systemctl stop nexus
$ sudo /bin/systemctl start nexus
三、参考
sudo (简体中文) wiki
https://wiki.archlinux.org/index.php/Sudo_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)
https://segmentfault.com/a/1190000007394449
https://www.ibm.com/developerworks/cn/linux/l-cn-rootadmin2/index.html
How do I edit /etc/sudoers from a script?
https://jin-yang.github.io/post/linux-systemd.html
https://stackoverflow.com/questions/323957/how-do-i-edit-etc-sudoers-from-a-script