2
[root@localhost ~]# vim /usr/lib64/sas12/smtpd.conf    
pwcheck_method: saslauthd
mech_list: PLAIN LOGIN
log_level:3

:wq

An error occurs.

"/usr/lib64/sas12/smtpd.conf" E212: Can't open file for writing.  

Why root can't open file for writing?

enter image description here

3

Check that the /usr/lib64/sas12 directory already exists:

root@host:~# ls /usr/lib64/sas12

If it is not the case, you must create the directory before attempting to create the file:

root@host:~# mkdir -p /usr/lib64/sas12
root@host:~# vim /usr/lib64/sas12/smtpd.conf

You vim command should now work as expected.

  • Thanks. I was actually doing a vi for a file inside a folder that did not exist. As: vi ~/bin/backup. – Bishwas Mishra Feb 19 at 9:33
0

Either the filesystem is mounted read-only or this is not a root permission problem but a vim feature. Use a different editor or change the file permissions (e.g. make root the file owner), edit the file, and change them back.

0

This can happen if there is a swap file as well at the same location which might set a lock on the file for editing.

example please look for the file

/usr/lib64/sas12/.smtpd.conf.swp

If this file exists, then you can't edit the file. Try removing it and then editing it should work.

0

you can get this error when there is "+a" attribute set on a file. the command chattr will allow, only, appending, but not deleting the existing file.

server123:/tmp # chattr +a manish
server123:/tmp # lsattr manish
-----a---------- manish

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.