Report this

What is the reason for this report?

sudo: unknown user: root - please help!

Posted on November 25, 2014

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: root:x:0:0:root:/root:/bin/bashing bin:x:1:1:bin:/bin:/sbin/nologin:

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.

E325: ATTENTION 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.



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

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.

Hi, and thank you for answering.

I followed a tutorial to set up the server and I think I did set up a new user with root privileges. I also changed the SSH default port and disabled root login.

I log on to the server like so - newusername@123.456.789. However I’ve always needed to use sudo to make changes so I assume that I didn’t set up the new user privileges correctly.

I just tried: /usr/sbin/visudo

I get this message: visudo: /etc/sudoers: Permission denied

I think I have a really big problem, like you say. What is the solution if I can’t access root?

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.