Linux 給用戶賦sudo權限


1. 修改/etc/sudoers文件:

# User alias specification

User_Alias SUDO_USER=install01

--> 如果需要設置多個用戶,則用逗號(,)分隔Alias SUDO_USER = install01,install02

# Cmnd alias specification

Cmnd_Alias CMD_TARGET=/bin/chmod, /bin/chown, /bin/tar, /bin/cp, /usr/bin/egrep, /bin/ls, /bin/rm, /bin/mkdir, /usr/bin/sed, /usr/bin/grep, /usr/bin/which, /opt/VRTSvcs/bin/ha*, /usr/sbin/crm*, /usr/bin/test, /bin/kill, /bin/mv, /bin/echo, /usr/bin/touch, /usr/bin/tee, /usr/bin/gzip, /bin/cat, /bin/mount, /bin/umount, /sbin/lvchange, /sbin/lvscan, /usr/bin/dos2unix, /bin/sh

Cmnd_Alias SU_TARGET=/bin/su - oracle*, /bin/su - app*, /bin/su - grid*

# User privilege specification

root ALL=(ALL) ALL

SUDO_USER ALL=(root)NOPASSWD: CMD_TARGET, SU_TARGET

 

 

2. 測試sudo權限是否生效:

linuxUSM:~ # su - install01

inst01@linuxUSM:~> sudo -l

User inst01 may run the following commands on this host:

(ALL) ALL

(root) NOPASSWD: /bin/chmod, /bin/chown, /bin/tar, /bin/cp, /usr/bin/egrep, /bin/ls, /bin/rm, /bin/mkdir, /usr/bin/sed, /usr/bin/grep, /usr/bin/which, /opt/VRTSvcs/bin/ha*, /usr/sbin/crm*, /usr/bin/test, /bin/kill, /bin/mv, /bin/echo, /usr/bin/touch, /usr/bin/tee, /usr/bin/gzip, /bin/cat, /bin/mount, /bin/umount, /sbin/lvchange, /sbin/lvscan

(root) NOPASSWD: /bin/su - ptl*, /bin/su - oracle*, /bin/su - grid*

 

inst01@linuxUSM:~> mkdir /etc/testdir

mkdir: cannot create directory `/etc/testdir': Permission denied

inst01@linuxUSM:~> sudo mkdir /etc/testdir

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM