[zabbix@zabbix sbin]$ ls -al /etc/sudoers
@H_
301_0@-r--r----- 1 root root 4085 Jul 11 14:49 /etc/sudoers
@H_
301_0@
添加修改权限以root身份
@H_
301_0@chmod 640 /etc/sudoers
@H_
301_0@vim /etc/sudoers
@H_
301_0@
添加如下两行
@H_
301_0@## Allow root to run any commands anywhere
@H_
301_0@
donald ALL=(ALL) ALL
@H_
301_0@需要密码sudo
@H_
301_0@## Same thing without a password
@H_
301_0@# %wheel ALL=(ALL) NOPASSWD: ALL
@H_
301_0@
%MysqL ALL=(ALL) NOPASSWD: ALL @H_301_0@%zabbix ALL=(ALL) NOPASSWD: ALL
@H_
301_0@无密码sudo
@H_
301_0@恢复
文件权限
@H_
301_0@chmod 440 /etc/sudoers
@H_
301_0@我的sudoers
文件:如下
@H_
301_0@[zabbix@zabbix sbin]$ sudo cat /etc/sudoers
@H_
301_0@## Sudoers allows particular users to run var
IoUs commands as
@H_
301_0@## the root user,without needing the root password.
@H_
301_0@##
@H_
301_0@## Examples are provided at the bottom of the file for collections
@H_
301_0@## of related commands,which can then be delegated out to particular
@H_
301_0@## users or groups.
@H_
301_0@##
@H_
301_0@## This file must be edited with the 'visudo' command.
@H_
301_0@
@H_
301_0@## Host Aliases
@H_
301_0@## Groups of machines. You may prefer to use hostnames (perhaps using
@H_
301_0@## wildcards for entire domains) or IP addresses instead.
@H_
301_0@# Host_Alias FILESERVERS = fs1,fs2
@H_
301_0@# Host_Alias MAILSERVERS = smtp,smtp2
@H_
301_0@
@H_
301_0@## User Aliases
@H_
301_0@## These aren't often necessary,as you can use regular groups
@H_
301_0@## (ie,from files,LDAP,NIS,etc) in this file - just use %groupname
@H_
301_0@## rather than USERALIAS
@H_
301_0@# User_Alias ADMINS = jsmith,mikem
@H_
301_0@
@H_
301_0@
@H_
301_0@## Command Aliases
@H_
301_0@## These are groups of related commands...
@H_
301_0@
@H_
301_0@## Networking
@H_
301_0@# Cmnd_Alias NETWORKING = /sbin/route,/sbin/ifconfig,/bin/ping,/sbin/dhclient,/usr/bin/net,/sbin/iptables,/usr/bin/rfcomm,/usr/bin/wvdial,/sbin/iwconfig,/sbin/mii-tool
@H_
301_0@
@H_
301_0@## Installation and management of software
@H_
301_0@# Cmnd_Alias SOFTWARE = /bin/rpm,/usr/bin/up2date,/usr/bin/yum
@H_
301_0@
@H_
301_0@## Services
@H_
301_0@# Cmnd_Alias SERVICES = /sbin/service,/sbin/chkconfig
@H_
301_0@
@H_
301_0@## Updating the locate database
@H_
301_0@# Cmnd_Alias LOCATE = /usr/bin/updatedb
@H_
301_0@
@H_
301_0@## Storage
@H_
301_0@# Cmnd_Alias STORAGE = /sbin/fdisk,/sbin/sfdisk,/sbin/parted,/sbin/partprobe,/bin/mount,/bin/umount
@H_
301_0@
@H_
301_0@## Delegating permissions
@H_
301_0@# Cmnd_Alias DELEGATING = /usr/sbin/visudo,/bin/chown,/bin/chmod,/bin/chgrp
@H_
301_0@
@H_
301_0@## Processes
@H_
301_0@# Cmnd_Alias PROCESSES = /bin/nice,/bin/kill,/usr/bin/kill,/usr/bin/killall
@H_
301_0@
@H_
301_0@## Drivers
@H_
301_0@# Cmnd_Alias DRIVERS = /sbin/modprobe
@H_
301_0@
@H_
301_0@# Defaults specification
@H_
301_0@
@H_
301_0@#
@H_
301_0@# Disable "ssh hostname sudo <cmd>",because it will show the password in clear.
@H_
301_0@# You have to run "ssh -t hostname sudo <cmd>".
@H_
301_0@#
@H_
301_0@Defaults requiretty
@H_
301_0@
@H_
301_0@#
@H_
301_0@# Refuse to run if unable to disable echo on the tty. This setting should also be
@H_
301_0@# changed in order to be able to use sudo without a tty. See requiretty above.
@H_
301_0@#
@H_
301_0@Defaults !visiblepw
@H_
301_0@
@H_
301_0@#
@H_
301_0@# Preserving HOME has security implications since many programs
@H_
301_0@# use it when searching for configuration files. Note that HOME
@H_
301_0@# is already set when the the env_reset option is enabled,so
@H_
301_0@# this option is only effective for configurations where either
@H_
301_0@# env_reset is disabled or HOME is present in the env_keep list.
@H_
301_0@#
@H_
301_0@Defaults always_set_home
@H_
301_0@
@H_
301_0@Defaults env_reset
@H_
301_0@Defaults env_keep = "COLORS DISPLAY HOSTNAME HISTSIZE INPUTRC KDEDIR LS_COLORS"
@H_
301_0@Defaults env_keep += "MAIL PS1 PS2 QTDIR USERNAME LANG LC_ADDRESS LC_CTYPE"
@H_
301_0@Defaults env_keep += "LC_COLLATE LC_IDENTIFICATION LC_MEASUREMENT LC_MESSAGES"
@H_
301_0@Defaults env_keep += "LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER LC_TELEPHONE"
@H_
301_0@Defaults env_keep += "LC_TIME LC_ALL LANGUAGE LINGUAS _XKB_CHARSET XAUTHORITY"
@H_
301_0@
@H_
301_0@#
@H_
301_0@# Adding HOME to env_keep may enable a user to run unrestricted
@H_
301_0@# commands via sudo.
@H_
301_0@#
@H_
301_0@# Defaults env_keep += "HOME"
@H_
301_0@
@H_
301_0@Defaults secure_path = /sbin:/bin:/usr/sbin:/usr/bin
@H_
301_0@
@H_
301_0@## Next comes the main part: which users can run what software on
@H_
301_0@## which machines (the sudoers file can be shared between multiple
@H_
301_0@## systems).
@H_
301_0@##
Syntax:
@H_
301_0@##
@H_
301_0@## user MACHINE=COMMANDS
@H_
301_0@##
@H_
301_0@## The COMMANDS section may have other options added to it.
@H_
301_0@##
@H_
301_0@## Allow root to run any commands anywhere
@H_
301_0@root ALL=(ALL) ALL
@H_
301_0@
donald ALL=(ALL) ALL
@H_
301_0@## Allows members of the 'sys' group to run networking,software,@H_
301_0@## service management apps and more.
@H_
301_0@# %sys ALL = NETWORKING,SOFTWARE,SERVICES,STORAGE,DELEGATING,PROCESSES,LOCATE,DRIVERS
@H_
301_0@
@H_
301_0@## Allows people in group wheel to run all commands
@H_
301_0@%wheel ALL=(ALL) ALL
@H_
301_0@
@H_
301_0@## Same thing without a password
@H_
301_0@# %wheel ALL=(ALL) NOPASSWD: ALL
@H_
301_0@
@H_
301_0@
%MysqL ALL=(ALL) NOPASSWD: ALL %zabbix ALL=(ALL) NOPASSWD: ALL ## Allows members of the users group to mount and unmount the ## cdrom as root # %users ALL=/sbin/mount /mnt/cdrom,/sbin/umount /mnt/cdrom ## Allows members of the users group to shutdown this system # %users localhost=/sbin/shutdown -h now ## Read drop-in files from /etc/sudoers.d (the # here does not mean a comment) #includedir /etc/sudoers.d