centos 中特定用户用sudo 执行命令不需要输入密码的设置

xiaoxiao2021-02-28  9

java用户在执行下面命令时不需要手动输入密码

sudo /usr/local/nginx/sbin/nginx -s reload

在/etc/sudoers文件中添加:

java ALL=(ALL) NOPASSWD: /usr/local/nginx/sbin/nginx

添加后的文件如下:

## Next comes the main part: which users can run what software on ## which machines (the sudoers file can be shared between multiple ## systems). ## Syntax: ## ## user MACHINE=COMMANDS ## ## The COMMANDS section may have other options added to it. ## ## Allow root to run any commands anywhere root ALL=(ALL) ALL centos ALL=(ALL) ALL java ALL=(ALL) NOPASSWD: /usr/local/nginx/sbin/nginx
转载请注明原文地址: https://www.6miu.com/read-1100177.html

最新回复(0)