5

How to I add my username to the sudoers file?

On my ubuntu desktop, the sudoer file has only root.

so basically, I will just need to adduser to sudo file system. And I need to access to single user mode.

I know the easiest way to to just select recovery mode in grub by hold down left Shift when booting. Then Drop to root shell prompt.

But it is ready-only file system. I need to write myself to the file.

I know I have to select remount first, but where is it?

and any other way to add myself to sudo?

Jin Lin
  • 151

2 Answers2

2

Sounds like a bit of a predicament you're in. If you've given your root account a password, su may allow you to elevate privileges and add your user to the group "sudo" or "admin".

If not, have you tried running a live CD? You should be able to mount your root partition from the Ubuntu live CD fairly easily, say to /mnt/tmproot/, and add this line somewhere in /mnt/tmproot/etc/sudoers:

username ALL=(ALL) ALL

where "username" is whatever your username is.

Marcus
  • 730
0

If your user name is as an example jlin, you should be able to sudo, if you entered your name as the sudo user when you installed Ubuntu.

If you want to add another user or if your username did not install Ubuntu, then you must log in as that user who installed Ubuntu, enter sudo -i to get root prompt; and then enter this command visudo.

I usually add the users I want to have sudo access. You can also add a group to have sudo access. I prefer just adding the users. I added a space in between the following, so it would format better.

# User_Alias ADMINS = jsmith, mikem

dbadmin ALL=(ALL) ALL

You can also use this command (as root)

sudo usermod -a -G sudo hduser