以创建的jenkins用户为例。
1、先以root用户的身份登录,然后执行visudo , 或者其他具有sudo 权限的用户执行 sudo visudo也是一样的
2、在打开的文件中找到
## Allow root to run any commands anywhere
root ALL=(ALL) ALL
在这一行下面添加用户名,然后保存退出,之后用户就具有使用sudo命令的权限了。
## Allow root to run any commands anywhere
root ALL=(ALL) ALL
jenkins ALL=(ALL) ALL
3、如果要让用户在使用sudo的时候不再需要输入密码,还需要修改刚才的文件visduo
## Allow root to run any commands anywhere
root ALL=(ALL) ALL
## Allows members of the 'sys' group to run networking, software,
## service management apps and more.
# %sys ALL = NETWORKING, SOFTWARE, SERVICES, STORAGE, DELEGATING, PROCESSES, LOCATE, DRIVERS
## Allows people in group wheel to run all commands
# %wheel ALL=(ALL) ALL
## Same thing without a password
# %wheel ALL=(ALL) NOPASSWD: ALL
将绿线所示的这一行的注释去掉启用,添加用户到这一行就可以了,然后保存退出。
执行命令:gpasswd -a jenkins wheel (jenkins是以我创建的用户名为例)
命令执行之后用户就不需要再输入密码了
修改之后
## Allow root to run any commands anywhere
root ALL=(ALL) ALL
jenkins ALL=(ALL) ALL
## Allows members of the '