Adding yourself to the sudoers file

Posted by glenn gillen on Monday, August 27, 2007

Posted in sudo, ssh, configuration


Now something I forgot to in the Apache setup instructions, but partially took for granted, was that you would have access to sudo. I prefer not to do everything as root, and it’s probably a good habit to get into for security’s sake.

The process is fairly straight forward. First you change to root and open up the sudoers files:


su
/usr/sbin/visudo

You’ll now have the file open for editing in vi. Now you need to move down (either the arrow keys or the letters j and k for up and down, usually) until you see a line that looks like:


root    ALL=(ALL)     ALL

That is stating that the user root is permitted to run whatever commands, on whatever machine, it likes. We may as well let you do the same, so add in a similar line below (press esc to go into normal mode in vi, then press the letter i to insert text) but with your username in place of root. Like:


yourusername   ALL=(ALL)   ALL

Save the file and quit (press esc for normal mode and then type q to issue a write and quit). Now when you want to run a command that requires root access, you just prepend it with the sudo command, like:


sudo /usr/sbin/adduser

You’ll be prompted for a password to run the command, you just type in whatever your password usually is and away it goes. It also means if you want to give other users root access on the box you just add a sudo entry for their account and you never need give out the root password.

Bookmark

Add to: Digg Add to: Del.icio.us Add to: Reddit Add to: StumbleUpon Add to: Slashdot Add to: Yahoo Add to: Google Add to: Blogmarks Add to: Technorati Add to: Newsvine Add to: Netvouz
blog comments powered by Disqus