为什么root无法打开文件进行写入?

sho*_*key 5 root permissions

[root@localhost ~]# vim /usr/lib64/sas12/smtpd.conf    
pwcheck_method: saslauthd
mech_list: PLAIN LOGIN
log_level:3
Run Code Online (Sandbox Code Playgroud)

:wq

发生错误。

"/usr/lib64/sas12/smtpd.conf" E212: Can't open file for writing.  
Run Code Online (Sandbox Code Playgroud)

为什么root无法打开文件进行写入?

在此处输入图片说明

Whi*_*olf 9

检查/usr/lib64/sas12目录是否已经存在:

root@host:~# ls /usr/lib64/sas12
Run Code Online (Sandbox Code Playgroud)

如果不是这种情况,您必须在尝试创建文件之前创建目录:

root@host:~# mkdir -p /usr/lib64/sas12
root@host:~# vim /usr/lib64/sas12/smtpd.conf
Run Code Online (Sandbox Code Playgroud)

您的vim命令现在应该按预期工作。