Tanveer’s Weblog

Configuring sudo

April 27, 2008 · Leave a Comment

Normally if you want to run a command which requires root privileges you first have to type ’su -’, type your root password and then type the command. However you can bypass this by using the ’sudo’ command. But first you have to configure it like this:

$ su -
Password: <- Give your root password here
# visudo

Now go below the line:

root    ALL=(ALL)       ALL

press a, and type the following

username ALL=(ALL)      ALL

where username is the username you use to login. Next press Escape.

Now, if you want to be promted for your root password each time you use the sudo command go to this line:

# %wheel        ALL=(ALL)       ALL

and with your cursor pointing on # press x

If you don’t want to be promted for your root password each time you use the sudo command go to this line:

# %wheel        ALL=(ALL)       NOPASSWD: ALL

and with your cursor pointing on # press x

**Note: Using sudo without having to type your root password may expose your system since anyone that gets access to that user may as well become root. So, be careful!

Next, press :wq to save and exit. (type the : as well)

Finally type:

# gpasswd -a username wheel

To test if you have done it correctly as a simple user type:

$ sudo whoami

If everything is working properly the command should return the word root.

**Note: For the rest of the guide I will be using the sudo command when I want to execute a command which requires root previleges. You can still use the normal su -c ‘command’ way.

Categories: Linux · Tips' n Tricks'

0 responses so far ↓

  • There are no comments yet...Kick things off by filling out the form below.

Leave a Comment