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.
Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.
Click below to sign up and get $200 of credit to try our products over 60 days!