Oops! I deleted my admin user

Asked by Iain Houston

Oh dear I'm snookered! Temporarily I hope!
I added a new user admin and then deleted him
I hadn't realised that admin was so pecial and now of course my administrator account no longer has administrator priveledges as although /etc/sudoers has the entry saying members of admin group can use the sudo command my administrator account is no longer associated with group 'admin' as a consequence, I suppose od deleting user 'admin' (I hope my understanding is correct!).
For this reason too I can't get into the visual 'user and groups' program to make sure 'admin' exists and that my administrator is a member of this group.
Would someone be kind enough to tell me how I restore this relationship using commands ... presumably in single user mode at root's prompt?
Many thanks in anticipation.

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Solved by:
Iain Houston
Solved:
Last query:
Last reply:
Revision history for this message
jon latorre (moebius-etxea) said :
#1

You are right. You have to startup in single user mode and when yo get a root account you have to type:

addgroup admin
adduser YOURUSER admin

Revision history for this message
Chris Coulson (chrisccoulson) said :
#2

First of all, you can check to see if your current user is a member of the admin group. To do this, type 'groups' in a terminal. You will see an output similar to this:

'chr1s adm dialout fax cdrom floppy tape audio dip video plugdev scanner admin lpadmin fuse tilp sambashare xp-write vmware chrisandjo-rw shared-rw'

If 'admin' is listed, then your user is a member of the admin group and you should be able to perform administrative duties. If your user is not a member of the admin group, and no other user on the system is, then your only option is to boot in to recovery mode.

Once you have booted in to recovery mode, type the following:

usermod -a -G admin <user_name>

...where '<user_name>' is your user name

Revision history for this message
Bhavani Shankar (bhavi) said :
#3

Hello lain:

This link may help you out:

http://www.psychocats.net/ubuntu/sudo

Note: To reset admin password:

reboot into GRUB (hit the appropriate key when it tells you on boot...you have 3 seconds or so to do it). Once you are in, go to (usually) the 2nd line and add "single" (no quotes) to the end of your kernel arguments. This will boot you into single user mode. Once you get a command shell, type 'passwd' (again, no quotes) and give it a new password...

Regards

Bhavani Shankar.

Revision history for this message
Iain Houston (iainhouston) said :
#4

Thanks so much everybody for your amazingly prompt responses! Amazing!
I followed jon latorre's advice and I am back in administrative business again!

FYI: when I booted into single user mode the addgroup command told me that 'admin' still existed as a group; so then the adduser command worked the necessary magic to re-establish my administrator as a member of 'admin'.

Thanks again everyone for helping me out of this hole!

Revision history for this message
Iain Houston (iainhouston) said :
#5

Perhaps I will raise a bug ... 'admin' is in effect a reserved word and I really shouldn't have been allowed to add the user 'admin'
what do you think?

Revision history for this message
TekZombie (tysonmock) said :
#6

I agree this should be changed. Ubuntu shouldn't allow anyone to add a username of "admin" due to this problem I had also ran into. Thank goodness I stumbled across this thread! However, I'm never going to get the last few hours of my life back trying to figure this one out. Oh well, chalk it up as a learning process along with everything else.

Revision history for this message
Constance Barkey (equimassage) said :
#7

Just bought a used Dell netbook with ubuntu on it. It was used so I do not have the administerator password. It does not boot into GRUB.