This is my first time with Debian and I don't really understand how to grant myself sudo access. I have a fresh install with a root password and a normal default user. I just want my normal default user to have sudo privilliges. So far I have done the following.

!entered password
apt-get install sudo
adduser [normal_default_user] sudo

It accepted the command but I still can't get access to sudo. I am already a bit confused, can someone explain how I can do what I'm trying to do please? I've seen people talk about using visudo, but the man page for it doesn't describe how to add a user to sudo, so I need your help.

  • Did you log out and back in? Group changes (which is what adduser does, it added the specified user to the group called `sudo) take effect when you log in. Jun 17 '15 at 23:04

You can also just create your user as normal, then login as root and add this in /etc/sudoers:

youruser ALL=(ALL) ALL

This says youruser can sudo and run any command as root without being prompted for a password on each command.

If you look at /etc/sudoers after running the command posted by Christopher, you will probably find that command created a line similar to the above.

  • It's not possible for me to edit that file. Also, I don't want to run everything as root. Chris's command doesn't work by the way. It doesn't accept the usermod command
    – john smith
    Jun 17 '15 at 20:14
  • Oh he's modified it to say -G, so now it works :)
    – john smith
    Jun 17 '15 at 20:15
  • As far as I know, you are not going to be able to just add yourself sudo. The system admin will have to add it for you. It is for 'privileged' users, so not everyone can just assume the ability for themselves.
    – Baazigar
    Jun 17 '15 at 20:16
  • 1
    Hilarious, since I'm the admin
    – john smith
    Jun 17 '15 at 20:16
  • If you are the admin, why can't you edit /etc/sudoers??
    – Baazigar
    Jun 17 '15 at 20:17

If your regular username is john:

$ su -
# apt-get install sudo
# usermod -a -G sudo john
# logout
$ logout

$ indicates a command executed as a regular user.

# indicates a command executed as the user, root.

Log in again as john and execute sudo -i to test.

  • Ok thanks Christopher. I will test this in a second. Can I ask what I've done using the last command in my post? I just need to work out if I need to undo that?
    – john smith
    Jun 17 '15 at 20:07
  • Thanks again. Can I ask you 1 more question since I'm learning how to use man pages. I just did a man usermod to try and work out what you did. -a means append, but I only see a -g (lower case) option. How am I normally supposed to find out how to use the G command there?
    – john smith
    Jun 17 '15 at 20:11
  • Thanks for your help. I couldn't logout though. It said I need to use "exit" twice. So I did that, and it still didn't work. But when I rebooted it worked. Do you know why? Sorry I can't tick or up vote you answer, I have not enough reputation on this forum.
    – john smith
    Jun 17 '15 at 20:23
  • I tested this just now, it does not work. Jul 22 at 18:11
  • @Christopher I just fresh installed Debian in a VM and it doesn't work. Baazigar's answer worked. Jul 23 at 20:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.