December 5, 2008

You are currently browsing the daily archive for December 5, 2008.

sudo revisited

UPDATED 4/12/09  –/etc/sudoers is normally read-only; added steps to change permissions as necessary

I had posted a method for setting up sudo (used for executing commands as “root” user) here:
http://blogs.ydl.net/billb/2008/03/05/su-sudo-no-jacket-required/

But, someone pointed out a different and probably better method on my forum here:
http://pleasantfiction.ipower.com/bodega/viewtopic.php?p=649#p649

1. Go to Applications->System Tools->Users & Groups in the menu (it will as for your root password at this point).

2. Select your username, click on the Properties icon, select the Groups tab.

3. Check the box next to the group called “Wheel”, click OK, and close the User Manager window.

4. Open a terminal window, make /etc/sudoers writable, and, as root, edit your /etc/sudoers file:

su -l
<root password>

chmod +w /etc/sudoers

gedit /etc/sudoers

Hit Ctrl-F to open the Find window and search for %wheel

## Allows people in group wheel to run all commands
# %wheel    ALL=(ALL)    ALL

Remove the # in front of %wheel so it looks like this:

## Allows people in group wheel to run all commands
%wheel    ALL=(ALL)    ALL

Save the file and close gedit.  Back on the terminal window, change the permission back to normal on the sudoers file, then type exit to go back to your regular user name.

chmod 0440 /etc/sudoers

exit

Note that you could remove the comment in front of %wheel in the section just below where it says, “## Same thing without a password,” but I prefer to have it ask for my password when running a potentially dangerous command.

That’s it … now you can use sudo intead of su, and if you have any other users that you want to set up sudo for just add them to the wheel group in the Users & Groups window.