1. Open a terminal.
2. In the terminal enter the following:
su –login -c ‘visudo’
3. Press enter, at the password prompt enter the password for root, then press enter.
4. A display similar to the following will be displayed:
# sudoers file.
## This file MUST be edited with the ‘visudo’ command as root.
## See the sudoers man page for the details on how to write a sudoers file.## Host alias specification# User alias specification
# Cmnd alias specification# Defaults specification# Runas alias specification# User privilege specification
root ALL=(ALL) ALL
# Uncomment to allow people in group wheel to run all commands
# %wheel ALL=(ALL) ALL
# Same thing without a password
# %wheel ALL=(ALL) NOPASSWD: ALL
# %users ALL=/sbin/mount /cdrom,/sbin/umount /cdrom
# %users localhost=/sbin/shutdown -h now
5. Below the line root ALL=(ALL) ALL add the user that you want to have root access as shown below:
sglaser ALL=(ALL) ALL
6. If you *want* sudo to prompt for a password, use the arrow keys to go down to the line that reads “# %wheel ALL=(ALL) ALL” and delete the # at the beginning of the line using the ‘x’ key (NOTE: it’s your own password, not roots).
7. If you do *NOT* want sudo to prompt for a password, use the arrow keys to go down to the line that reads “# %wheel ALL=(ALL) NOPASSWD: ALL” and delete the # at the beginning of the line using the ‘x’ key.
Once you have uncommented one of the lines, press “ESC” then enter the following to save the changes :
8. OPTIONAL: If you want to be able to use sudo without having to type the full root path every time (e.g.: /sbin/fdisk), on a per-user instead of system-wide default, then you should prefix root’s command path to your user’s PATH variable in ~/.bash_profile. Change it to:
9. To add users to the Wheel Group from the command line perform the following:
su -c ‘gpasswd -a username wheel’
At the password prompt enter the password for the root user, then press enter.