vim出现“E212: Can't open file for writing”的处理办法
在使用vim 对文件或配置进行编辑的时候,在保存时发现当前用户没有写权限。又不想放弃当前编辑的内容,怎么办呢? 来自stackoverflow
“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.
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 like sudo vim FILE. Or if you don't want to leave your existing vim session (and know have proper sudo rights), you can issue:
:w !sudo tee % > /dev/null
Which will save the file. ”
这样文件的所有者是root,依然没有写的权限。只需更改文件的所有者和组:
[sany@sanshui code]$ sudo chown 用户名:组名 文件名
当你用上述方法强制写的时候,会提示如下:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.
【linux总是这么可爱
】
vim出现“E212: Can't open file for writing”的处理办法的更多相关文章
- "etc/profile" E212: Can't open file for writing
今天安装Java环境,出现如下错误: "etc/profile" E212: Can't open file for writing 这是安装到本地JDK路径不正确导致.怎么办呢? ...
- Linux :: vi E212: Can't open file for writing
Linux :: vi E212: Can't open file for writing sysct1.conf 可能无写权限!查看方法:ls -lh /etc/sysct1.conf如果没有,则c ...
- E212: Can't open file for writing Press ENTER or type command to continue
E212: Can't open file for writing Press ENTER or type command to continue 出现这个错误的原因可能有两个: 1.当前用户的权限不 ...
- vi 新建编辑文件时报错 E212 can’t open file for writing
在vi修改防火墙配置时,不能够保存,报E212 can’t open file for writing错误. 网上大概给出了两种答案. 一是权限不够,可以用root权限事实,或者sudo 操作. 二是 ...
- Linux下使用vi新建文件保存文件时遇到错误:E212: Can't open file for writing
出现E212: Can't open file for writing的问题是由于权限问题导致的,解决方法有以下思路: 1.使用root进行登录,然后再操作. 2.在使用命令时,前面加sudo. 3. ...
- E212: Can't open file for writing
意思是不能保存. 原因是权限不够,普通用户用vi 进行不了保存,需要使用超级用户才可以 命令:sudo su 转换成超级用户 vi hello 打开文件 :wq 即可保存退出
- /etc/apt/sources.list" E212: Can't open file for writing解决方案
:w !sudo tee % > /dev/null 解决.
- 编辑文件出现:E212 can’t open file for writing
前面目录没有创建 还可能是权限问题
- vim中 E212:无法打开并写入文件 的解决办法
因为centos7刚安装的时候是无法上网的,所以,需要去配置一下ifcfg-ens33文件,但实际上这个文件是只读的文件,root也无法去更改内容,这时候保存的时候需要使用 w ! sudo tee ...
随机推荐
- django2.0数据展示流程
之前刚刚实现了数据添加的流程,那么数据展示是怎么回事 1 先在 views.py 中定义函数 增加获取数据的方式 from django.shortcuts import render from bl ...
- Pyhton项目实践:将带有美国风格日期的文件改名为欧洲风格日期
题目 项目要求:上千个文本文件,文件名包含美国风格的日期( MM-DD-YYYY),需要将它们改名为欧洲风格的日期( DD-MM-YYYY) 先写个创建一百个美国风格日期的文件 #! python # ...
- 在线OFFICE方案
Office在线预览及PDF在线预览的实现方式大集合 在线浏览office 文件 在线预览文档openoffice+swfTool 类百度文库文档上传.转换和展示功能项目开源代码 微软的office ...
- WordPress无法发送电子邮件,可能原因:您的主机禁用了mail()函数解决方案
体验更优排版请移步原文:http://blog.kwin.wang/website/wp-cant-send-email-solution.html 最近折腾了下WordPress,给米表 搭了个论坛 ...
- firemonkey Grid自定义
http://stackoverflow.com/questions/28893564/memory-leak-on-tstringgrids-ondrawcolumncell-event http: ...
- delphi 路径函数
delphi path functionIncludeTrailingPathDelimiterIncludeTrailingPathDelimiter ensures that a path nam ...
- [ShaderStaff] Vignette Effect
操作系统:Windows8.1 显卡:Nivida GTX965M 开发工具:GLSL | C 最近在看Cardboard实现,其中关于畸变的着色器代码中有加入 晕影Vignette 效果的实现,固在 ...
- The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path问题的解决
这个问题的解决有二种解决办法: 1.加apache tomcat的运行环境即可 选中项目点击右键 以上这种做法是在eclipse中的做法 2.如果是maven工程,还可以采用maven做法 就在这个工 ...
- css常用属性总结:文本属性中的text-indent
在网页中的文本格式中最重要的效果之一就是段落的首行文本缩进,尤其在新闻类页面,使用text-indent,任何元素都可以让首行以给定的长度缩进, 长度甚至可以是负数,这一属性的最常用方式就是段落的首行 ...
- 克拉 & 24K
[克拉] 克拉(Ct)是宝石的质量(重量)单位,现定1克拉等于0.2克或200毫克.一克拉又分为100分,如50分即0.5克拉,以用作计算较为细小的宝石.因为宝石的密度基本上相同,因此越重的宝石体积越 ...