Pages

Sunday, February 20, 2011

sudoers

If you want to allow a user to run a command as another user, /etc/sudoers file should be used. Usually it's necessary for a user to run a command as root, equivalent to the Windows "Run as administrator". That is quite straight forward. Add in /etc/sudoers:

username ALL=NOPASSWD: /usr/sbin/ntpdate

Now this will be allowed:

username@laptop:~$ sudo /usr/sbin/ntpdate

There is another situation: when you need user1 to run a command as user2. For this you add to /etc/sudoers:

user1 ALL=(user2) NOPASSWD: /home/user1/bin/start_daemon

In this case user1 will be able to do:

user1@laptop:~$ sudo -u user1  /home/user1/bin/start_daemon

No comments:

Post a Comment