Ubuntu: I accidentally deleted or replaced my administrator account


I need your help.

I tried to change my username to another one by using the following commands:

sudo usermod -l new_username current_username  sudo mv /home/current_username new_username  sudo usermod -d /home/new_username  sudo chown -R new_username /home/new_username  

(without any password change).

Afterwards, I restarted my computer. I was suprised to see that the only available username was my previous one and the respective password didn't work anymore. I tried to fix the problem by selecting recovery mode and by using the following commands:

Select drop to root shell from the recovery menu.

Use the following command to remount the drive mount - o rw, remount /

ls /home  useradd username -m -s /bin/bash  passwd username   adduser username sudo  reboot  

However, the problem remains. Is there another way I can recover access to my administrator account?

Thank you in advance.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »