Why root Can’t open file for writing

permissionsroot

[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

Best Answer

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.

Related Question