我尝试使用 vi 编辑器编辑sources.list,但在保存文件时出现以下错误:
/etc/apt/sources.list" E212: Can't open file for writing
最佳答案
Vim 有一个内置的帮助系统。在 Vim 中运行 :h E212
会打印以下内容:
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.
您可能想以 super 用户身份使用 sudo vim FILE
编辑该文件。或者,如果您不想离开现有的 vim session (并且现在拥有适当的 sudo 权限),您可以运行:
:w !sudo tee % > /dev/null
这将保存文件。
关于vi -/etc/apt/sources.list"E212 : Can't open file for writing,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8253362/