Wednesday, 29 December 2010

Adding user to Sudoers file

I remember my first time exploring Linux distros outside the safety of Ubuntu. One of the very first things that confused me was when I tried to use the sudo command I was greeted with the message:
kevie is not in the sudoers file. This incident will be reported.
In the community we are often guilty of assuming things we do regularly are known to all users, but we all lacked knowledgable at one time. Well the first thing that is important is how to add the user to the sudoers file.

1. open the terminal

2. type su (then enter your password)

3. type visudo

this will then bring up a screen full of characters, you can scroll around, but you'll notice that we can't start typing right away, we are in the editor called vi

4. scroll down to the line root ALL=(ALL) ALL

5. press i to start editing the file

6. below the line in step 4 enter {your user name} ALL=(ALL) ALL

7. stop editing by pressing the escape(esc) key

8. assuming everything went alright* enter :wq to save and exit the file

*if you accidentally changed something you shouldn't have :q! will exit without saving the file. If you need to do this type the command and go back to step 3.

You are now in the sudoers file and can use sudo to gain superuser privileges. But remember:
With great power comes great responsibility
The second question you'll be asking yourself is "Who does the first 'illegal' use of sudo get reported to?" Well the following illustration should help:

No comments:

Post a comment