centos 添加sudo权限

前端之家收集整理的这篇文章主要介绍了centos 添加sudo权限前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
[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 varIoUs 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

猜你在找的CentOS相关文章