And i wish to ask how should i allow a list of command to be allowed to used for a member of a particular group in SUDOERS FILE. i dont know how to formulate in the below code from sudoers file
Interesting. I hadn't heard of this before, but from some quick Googlings it seems that this is the default behaviour of sudo on openSUSE. If you edit the sudoers file you'll probably find a line like this:
Defaults targetpw
If you comment that line out, then sudo should prompt for the user's own password rather than the password for the root account.
On to your second point, specifying commands a user or group can run. That can be done with an entry like this (in this case, I'm specifying the commands that members of the unixforum group can run without being prompted for a password):
may i ask why percentage in front of uniform group name is written ..does it has special meaning.
and from the above code , is there a special way of representing if its username or group name.
---------- Post updated at 11:29 AM ---------- Previous update was at 10:34 AM ----------
i have tried to make a particular user name james to able to open and edit sudoers file . but seems something went wrong . can u help me out with that
james@opensuse:~> visudo
Absolute path to 'visudo' is '/usr/sbin/visudo', so running it may require superuser privileges (eg. root).
james@opensuse:~>
The percent sign (%) at the start of the line signifies that this is a UNIX group name, and not a username. So it will affect all members of the group called unixforum , and not simply one single user. Lines without a percent symbol would affect only individual users and not groups.
The point of the sudoers file is to specify commands that users can run, not to list all the files or things they can access. So putting the sudoers file itself in the sudoers file doesn't actually make any sense. You also missed out the space between the colon and the command list, which may be important in your implementation.
So, if you wanted to give the user james permission to use sudo to edit the sudoers file, you'd actually want a line like this:
james ALL=NOPASSWD: /usr/sbin/visudo
It's worth pointing out that this isn't actually a good idea at all. Letting a user edit the sudoers file themselves via sudo is very dangerous and not at all secure, since they could then give themselves permission to run anything at all. If you're going to do that you might as well let the user run any and all commands without a password, since all you're really using sudo for at that point is to get a passwordless su .
There is a book called "Sudo Mastery- User Access Control for Real People" by Michael W Lucas. I find it very useful for understanding the sudo configuration as he explains it in simple terms.