Transfer root privilege to a user all. |
[root@dlp ~]# # add at the last line: user 'cent' can use all root privilege sharif ALL=(ALL) ALL # how to write ⇒ destination host=(owner) command # make sure with user 'cent' [sharif@dlp ~]$ /sbin/shutdown -r now shutdown: Need to be root # denied normally [ sharif @dlp ~]$ Password: The system is going down for reboot NOW! # own password # just executed |
[2] | In addition to the setting [1], set that some commands are not allowed. |
[root@dlp ~]# # near line 49: add aliase for the kind of shutdown commands Cmnd_Alias SHUTDOWN = /sbin/halt, /sbin/shutdown, \ /sbin/poweroff, /sbin/reboot, /sbin/init # add ( commands in aliase 'SHUTDOWN' are not allowed ) sharif ALL=(ALL) ALL, !SHUTDOWN # make sure with user ' sharif ' [ sharif @dlp ~]$ Sorry, user cent is not allowed to execute '/sbin/shutdown -r now' as root on |
[3] | Transfer some commands with root privilege to users in a group. |
[root@dlp ~]# # near line 51: add aliase for the kind of user management comamnds Cmnd_Alias USERMGR = /usr/sbin/useradd, /usr/sbin/userdel, /usr/sbin/usermod, \ /usr/bin/passwd # add at the last %usermgr ALL=(ALL) USERMGR groupadd usermgr [root@dlp ~]# vi /etc/group # add a user in this group usermgr:x:502: cent # make sure with user 'cent' [ sharif @dlp ~]$ [ sharif @dlp ~]$ # done normally [ sharif @dlp ~]$ Changing password for user testuser. New UNIX password: # set testuser's password Retype new UNIX password: passwd: all authentication tokens updated successfully. |
[4] | Transfer a command with root privilege to a user. |
[root@dlp ~]# # add at the last sharif ALL=(ALL) /usr/sbin/visudo # make sure with user 'cent' # possible to open and edit ## Sudoers allows particular users to run various commands as ## the root user, without needing the root password. ## # make sure with user 'fedora' [fedora@dlp ~]$ [fedora@dlp ~]$ # done normally # make sure with user 'ubuntu' # possible to open and edit # grub.conf generated by anaconda # # Note that you do not have to rerun grub after making changes to this file # NOTICE: You have a /boot partition. This means that |
[5] | The logs for sudo are kept in '/var/log/secure', but there are many kind of logs in it. So if you'd like to keep only sudo's log in a file, Set like follows. |
[root@dlp ~]# # add at the last Defaults syslog=local1 [root@dlp ~]# # The authpriv file has restricted access.vi /etc/rsyslog.conf # line 42: add local1.* /var/log/sudo.log authpriv.* /var/log/secure[root@dlp ~]# /etc/rc.d/init.d/rsyslog restart |
0 comments:
Post a Comment