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 ...
随机推荐
- Plex音乐名称乱码原因id3版本
标签编码支持情况: ID3v1:ISO-8859-1ID3v2 2.3:ISO-8859-1.UTF-16ID3v2 2.4:ISO-8859-1.UTF-16.UTF-8APEv2:UTF-8 修改 ...
- Vue 目录结构分析 数据绑定 绑定属性 循环渲染数据 数据渲染
一.目录结构分析 node_modules 项目所需要的各种依赖 src 开发用的资源 assets 静态资源文件 App.vue 根组件 main.js 配置路由时会用 .babelrc 配置文件 ...
- Python2.X如何将Unicode中文字符串转换成 string字符串
Python2.X如何将Unicode中文字符串转换成 string字符串 普通字符串可以用多种方式编码成Unicode字符串,具体要看你究竟选择了哪种编码:unicodestring = u&q ...
- 20165233 实验一 Java开发环境的熟悉
20165233 实验一 Java开发环境的熟悉 实验要求 1.没有Linux基础的同学建议先学习<Linux基础入门(新版)><Vim编辑器> 课程: 2.完成实验.撰写实验 ...
- ES6系列_15之class类的使用
JS语言的传统方法是通过构造函数,定义并生成新对象,是一种基于原型的面向对象系统.在ES6中新增加了类的概念,可以使用 class 关键字声明一个类,之后以这个类来实例化对象.1.先来看看es5与es ...
- Win7+Ubuntu12.04(EasyBCD硬盘安装)
安装双系统 Windows7 + Ubuntu12.04 软件准备 准备两个东西EasyBCD软件和iso镜像(我用的easybcd是2.2版,就下载1.7之后版就行,要那种安装版的,不要绿色版) E ...
- lombok 注解使用
需要引入: <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok&l ...
- 自定义annotation-----转载
Java从JDK5.0开始便提供了四个meta-annotation用于自定义注解的时候使用,这四个注解为:@Target,@Retention,@Documented 和@Inherited. @T ...
- nice & renice
[nice & renice & getpriority & setpriority] 1.nice & renice 参考:http://man.ddvip.com/ ...
- Mybatis自动生成xml文件、dao接口、实体类
Mybatis可以通过逆向工程,实现自动生成xml文件.dao接口.实体类 以下使用的是Intellij Idea进行自动生成 一.首先,要在pom.xml中导入插件,在<build>中加 ...