Saturday, October 30, 2010

HOWTO: Give user sudo right in Ubuntu

Recently, on my laptop I had to create two new users and give them sudo access. In Ubuntu/Kubuntu Lucid Lynx, this is very easy. Just do the following:

1. Click on "System Settings" in the K menu


2. Click "Advanced" under System Settings and select "User Management" to add a new user.



3. Add your new user, type in their username and other relevant details



4. Click on "Privileges and Groups" and select the following two checkboxes, giving the user the right to administer the system and adding him/her to the "admin" group.



Of course, if you're a power user, you probably already know how to add give someone the privilege of sudo access. But if you're interested in learning, read on.

In a terminal (konsole, kterm, gterm, xterm etc..), type:

sudo visudo

This assumes that you have sudo access, which you do, if you're the default user on a new Ubuntu install. visudo is the program used to manipulate the /etc/sudoers file, which stores the users who are allowed to preface their commands with sudo.

Manually editing this file with nano or vi is not recommended, because it can break sudo functionality, and  once you make your incorrect changes and save the file and exit, you may not be able to start another sudo session to fix the file. Please stick to the visudo program to edit the /etc/sudoers list. But I digress. Back to adding your user to the file. In visudo simply add your new user to the end of the file.

Find the line:
root    ALL=(ALL) ALL

and add your new user below it, as:

yossarian    ALL=(ALL) ALL

Save the file with [ESC], followed by typing in "wq" without the quotes and hitting [ENTER]. We're done. The new user yossarian should have sudo access now.

No comments:

Post a Comment