Renamed root in /etc/passwd and now sudo does not work

4

I accidentally modified the line for root in /etc/passwd and changed its named. To fix it I tried using sudo to modify this file, but it does not let me sudo because sudo can't find the root user since I renamed it.

II am on ubuntu.

aafc

Posted 2012-12-11T21:00:36.207

Reputation: 43

Answers

6

Try :

sudo -u new_wrong_root_user

If you can't, reboot on a live-cd, then in terminal :

mkdir target
mount /dev/sda1 target # sda1 if / is the first partition of the first drive
vim target/etc/passwd

Gilles Quenot

Posted 2012-12-11T21:00:36.207

Reputation: 3 111

sudo -u worked. – aafc – 2012-12-11T21:15:49.713

0

If @sputnick's answer does not work, another solution would be to boot a live disc and mounting your drive in that, then use the live root user to adjust it.

nerdwaller

Posted 2012-12-11T21:00:36.207

Reputation: 13 366

sputnick does mention that possibility (perhaps a grace period edit), so this answer doesn't really make a lot of sense... – a CVn – 2014-10-17T08:32:34.223