Sunday, May 31, 2009

Adding Users to Sudoers File

Users can execute commands that are usually restricted to the root account using sudo program. The sudo configuration file is /etc/sudoers.

Open /etc/sudoers file with your favorite text editor as root, then remove comment character, #, in front of line "%wheel ALL=(ALL) ALL" and save.

# visudo

or

# nano /etc/sudoers


...
# Uncomment to allow people in group wheel to run all commands
# %wheel ALL=(ALL) ALL

...

Change above line as in below and save file.
...
# Uncomment to allow people in group wheel to run all commands %wheel ALL=(ALL) ALL
...

You need to add your user name to group wheel also.


# gpasswd -a user wheel

(Replace user with your user name)

Now you can execute some privileged commands using sudo as user without becoming root with su. For example it is possible to edit system file inittab as user executing below command.

# sudo nano /etc/inittab

Picture source: http://xkcd.com/149/

4 comments:

  1. thanx for this information.
    now sudo can make a coffe

    ReplyDelete
  2. THANKS! I had tried previously making a sudo group, but permissions were a problem.

    LK

    ReplyDelete
  3. I did it on slackware 14 but I'm still having this return:
    " is not in the sudoers file. This incident will be reported."
    There is any other suggestion?

    ReplyDelete