Some times you need to allow you users to run a few root commands for example few of my users works on testing server have to restart and shutdown linux servers, which is not allowed by normal users. If you a normal user try to shutdown server with halt command server replies ACCESS DENIED. So in this post we'll see how to give permission for that command useing SUDOERS file.
Add user you want and the full path of the command, see below example for a user testuser and halt command
Add user you want and the full path of the command, see below example for a user testuser and halt command
[root@server]# vim /etc/sudoers
testuser ALL = /sbin/halt
testuser ALL = /sbin/halt
Once you edit the file and entered the users and commands you want to give access for can be executed by permitted users followed by sudo but user have to give his user password every time he uses the command.
Lets try halt command as testuser/
[root@server]# su testuser
[testuser@server]# sudo halt
[sudo] password for testuser:
The system is going down for halt NOW!
testuser ALL = NOPASSWD: /sbin/halt
[testuser@server]# sudo halt
[sudo] password for testuser:
The system is going down for halt NOW!
testuser ALL = NOPASSWD: /sbin/halt
That's it, if you don't want asking password every time just add NOPASSWD: to it.
[root@server]# vim /etc/sudoers
testuser ALL = NOPASSWD: /usr/bin/pkil
testuser ALL = NOPASSWD: /usr/bin/pkil
That 's it just enter the halt command followed by sudo without password.
gil...



6:39 PM
GIL
Posted in:
0 comments:
Post a Comment