Configuring sudo

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.

Advertisements

About Tanveer
RIA (Rich Internet Application) Developer with a wide variety of business applications. Particularly interested in client/server and relational database design. Always interested in migration projects, as well as close interaction with the DB manufacturers.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: