sudo: unknown user: root - please help!
I was using terminal, and vim, to edit my /etc/passwd file and got a ‘broken pipe’ message in the window. I have CentOS
When I logged back onto the server I tried to access the file again using sudo.
I got the following:
sudo: unknown user: root
sudo: unable to initialize policy plugin
I can open the file without sudo, and notice there are a couple of lines that were at beginning of the list that have disappeared - Luckily I’ve been keeping a 'diary’ of what I’ve been doing over the past couple of months so have a print-out of the contents of passwd.
The missing lines are:
I’m able to copy the missing lines back but the file won’t save.
At the bottom of the window I see:
“/etc/passwd” [readonly] 29L, 1454C
When I hit 'ESC :wq’ I see:
E45: 'readonly’ option is set (add ! to override)
I’ve tried all manner of ways including ’:w !sudo tee %’ to try to get this file to save but to no avail.
I also discovered another warning that momentarily displayed then disappeared. I managed to get a screen shot of it.
Found a swap file by the name “var/tmp/passwd.swp”
While opening file “/etc/passwd”
(1) Another program may be editing the same file.
(2) An edit session for this file crashed.
If this is the case, use “:recover” or “vim -r /etc/passwd”
to recover the changes (see “:help recovery”).
If you did this already, delete the swap file “/var/tmp/passwd.swp”
to avoid this message.
Can anyone give me any suggestions please? I’ve spent all day trying to figure it out but I’m fairly new to all this.
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.