vi -/etc/apt/sources.list"E212 : Can't open file for writing

标签 vi ubuntu-11.04

我尝试使用 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/

相关文章:

regex - vi:::s 如何只替换一行中的第二次出现?

Bash vi 模式 - 绑定(bind) "C-c"以退出插入模式

mysql - Rails 3.2.3 MySQL 5.5.1 Mysql2 gem 安装因 ld 不兼容而失败

c++ - OpenCV,C++ : Inserting into set

python - Apache + mod_wsgi + 持久性 Python 应用程序 - 我想我错过了一 block

deployment - unicorn 崩溃循环

c++ - 如何在另一台计算机(linux)上使用 OpenCV 运行 C++ 库?

vim - 如何在每次打开 Vim 之前执行一个文件

linux - 我怎样才能保留数字以便以后对它们进行排序?

regex - 如何在vim中使用正则表达式来替换递增的数字变量