I unexpectedly deleted my user account (the only administrator for the machine). I have another account which is a standard account and now I can't access my hard disk or anything with that standard account - it is asking for the root password. Is there any way I can recover access to the administrator account?
-
Related: How do I add myself back as a sudo user? I'm not sure if we should consider this a duplicate. Probably not, since this has answers about how to create a new account (and that's about how to make an existing account an administrator account). – Eliah Kagan Jul 31 '13 at 21:03
3 Answers
You can use recovery mode to add the standard user to the admin group (which is now called sudo in 12.04). Below is a set of simple instructions copied from my personal website.
Using Recovery Mode To Add Users To The Admin / Sudo Group
First shutdown your computer.
Then restart whilst holding shift
on the keyboard to load grub menu.
Select recovery mode
from the grub menu.
Select drop to root shell
from the recovery menu.
Use the following command to remount the drive mount -o rw,remount /
Now type adduser username sudo
replacing username with your user name ie. 'adduser phil sudo'
You should now see a message saying 'adding user' followed by 'done'.
Type shutdown -r now
to restart the computer.
EDIT: If it is telling you that user xxx does not exist, first you can use the following command to list users and make sure that you have the correct username
ls /home
The other option is add a new user, from recovery mode using the following commands :
useradd username -m -s /bin/bash
passwd username
adduser username sudo
Again replacing username
with your desired username.

- 3,899
-
whilie in adduser comand it is showing user XXX does'nt exist please help me. – Niranjan Jul 08 '12 at 13:05
-
@Niranjan - I have edited the answer to include the information you need. :o) – Fernhill Linux Project Jul 08 '12 at 13:18
You can use the recovery console and boot as root this is a extra option on your grub menu and create a new user then add them to the admin group. I'm not sure if this will fix your issue, but give it a try and let me know.
useradd newuser
adduser newuser admin

- 3,899

- 4,724
- 2
- 33
- 51
I had the same problem Select recovery mode (if you are using laptop it differents but it's in the same place you get in bios) Then select root Write the command(# adduser ) Then the command(# password root) And write the new password And restart by the command( #reboot)

- 1
-
1this is a bad idea. The root account is disabled in Ubuntu for security/safety reasons – Zanna Jun 05 '17 at 07:48
-
I have a problem now I loved in but I can't use mu computer normally can you help me – Mohamed Jun 06 '17 at 03:14
-