I am trying to edit sources.list using vi editor but getting the following error while saving the file:
/etc/apt/sources.list" E212: Can't open file for writing
I am trying to edit sources.list using vi editor but getting the following error while saving the file:
/etc/apt/sources.list" E212: Can't open file for writing
Try to connect as root and then edit file. This works for me
Or perhaps you are on a readonly mounted fs
I referenced to Zsolt in level 2, I input:
and then in my situation, I still can't modify the file, so it prompted that add "!". so I input
then it works
for me worked changing the filesystem from Read-Only before running vim:
Vim has a builtin help system. I just quoted what it says to
:h E212
.You might want to edit the file as a superuser as
sudo vim FILE
. Or if you don't want to leave your existing vim session (and now have proper sudo rights), you can issue:Which will save the file.
HTH
It might be possible that the file you are accessing has a swap copy (or swap version) already there in the same directory
Hence first see whether a hidden file exists or not.
For example, see for the following type of files
By using the command
And then, delete it using ...
Usually, I recommend to start using super user privileges using ...