Can't Open File For Writing Vim
4 Answers 4
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.
answered Oct 29 '17 at 12:38
WhiteWinterWolfWhiteWinterWolf
2,701 1 gold badge 18 silver badges 36 bronze badges
1
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.
answered Oct 29 '17 at 12:09
Hauke LagingHauke Laging
77.8k 17 gold badges 116 silver badges 168 bronze badges
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
answered Sep 27 '18 at 12:54
1
-
This solved my problem, thx
Nov 22 '19 at 1:33
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.
answered Jul 2 '18 at 9:06
Not the answer you're looking for? Browse other questions tagged permissions root or ask your own question.
Can't Open File For Writing Vim
Source: https://unix.stackexchange.com/questions/401203/why-root-cant-open-file-for-writing/401215
Posted by: smithrecognot40.blogspot.com
Thanks. I was actually doing a vi for a file inside a folder that did not exist. As:
vi ~/bin/backup
.Feb 19 '19 at 9:33