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
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Vim has a builtin help system. Running :h E212 inside Vim prints the following:
For some reason the file you are writing to cannot be created or overwritten. The reason could be that you do not have permission to write in the directory or the file name is not valid.
You might want to edit the file as a superuser with sudo vim FILE. Or if you don’t want to leave your existing vim session (and now have proper sudo rights), you can run:
:w !sudo tee % > /dev/null