banner



Vim Can't Open File For Writing

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

1

  • 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

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

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.

Vim Can't Open File For Writing

Source: https://unix.stackexchange.com/questions/401203/why-root-cant-open-file-for-writing/401215

Posted by: cornettinglacrievor.blogspot.com

0 Response to "Vim Can't Open File For Writing"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel