# /etc/sudoers
#
# This file MUST be edited with the 'visudo' command as root.
#
# See the man page for details on how to write a sudoers file.
#
Defaults env_reset
# Host alias specification
# User alias specification
# Cmnd alias specification
# User privilege specification
# 針對(duì)每個(gè)用戶設(shè)定權(quán)限
# 以下是指,對(duì)于root用戶,不論來(lái)自何方,可以切換到本機(jī)上的所有賬戶,并執(zhí)行所有的命令。
root ALL=(ALL) ALL
#calvin ALL=(ALL) NOPASSWD: ALL
# Uncomment to allow members of group sudo to not need a password
# (Note that later entries override this, so you might need to move
# it further down)
# %sudo ALL=NOPASSWD: ALL
# Members of the admin group may gain root privileges
# 加上%表明針對(duì)admin這個(gè)組來(lái)設(shè)定,由于calvin屬于admin組,因此如果在前面針對(duì)calvin這個(gè)用戶設(shè)定了NOPASSWD:,而在這里沒(méi)有設(shè)置,那么這里會(huì)覆蓋之前的設(shè)置,也就是說(shuō)使用sudo時(shí)還是會(huì)要求輸入密碼。
# 使用sudo -l可以查看自己在sudoer中的設(shè)定。
%admin ALL=(ALL) NOPASSWD: ALL
#
# This file MUST be edited with the 'visudo' command as root.
#
# See the man page for details on how to write a sudoers file.
#
Defaults env_reset
# Host alias specification
# User alias specification
# Cmnd alias specification
# User privilege specification
# 針對(duì)每個(gè)用戶設(shè)定權(quán)限
# 以下是指,對(duì)于root用戶,不論來(lái)自何方,可以切換到本機(jī)上的所有賬戶,并執(zhí)行所有的命令。
root ALL=(ALL) ALL
#calvin ALL=(ALL) NOPASSWD: ALL
# Uncomment to allow members of group sudo to not need a password
# (Note that later entries override this, so you might need to move
# it further down)
# %sudo ALL=NOPASSWD: ALL
# Members of the admin group may gain root privileges
# 加上%表明針對(duì)admin這個(gè)組來(lái)設(shè)定,由于calvin屬于admin組,因此如果在前面針對(duì)calvin這個(gè)用戶設(shè)定了NOPASSWD:,而在這里沒(méi)有設(shè)置,那么這里會(huì)覆蓋之前的設(shè)置,也就是說(shuō)使用sudo時(shí)還是會(huì)要求輸入密碼。
# 使用sudo -l可以查看自己在sudoer中的設(shè)定。
%admin ALL=(ALL) NOPASSWD: ALL
參考:http://sial.org/howto/sudo/