[root@localhost ~]# vim /usr/lib64/sas12/smtpd.conf pwcheck_method: saslauthd mech_list: PLAIN LOGIN log_level:3
An error occurs.
"/usr/lib64/sas12/smtpd.conf" E212: Can't open file for writing.
Why root can't open file for writing?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
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
vim command should now work as expected.
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.
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
If this file exists, then you can't edit the file. Try removing it and then editing it should work.
you can get this error when there is "+a" attribute set on a file.
chattr will allow, only, appending, but not deleting the existing file.
server123:/tmp # chattr +a manish server123:/tmp # lsattr manish -----a---------- manish