博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Vim保存只读模式下的修改
阅读量:6918 次
发布时间:2019-06-27

本文共 396 字,大约阅读时间需要 1 分钟。

用 vim 打开没有写权限的文件而忘记用 sudo 时,文件变成 read-only

这时候用 :w!SHIFT+ZZ,或者 qw! 都无法保存

:w !sudo tee %

:w : Write a file.可以将文件写入,文件仍然是只读模式,通过 :q! 退出

  • !sudo : Call shell sudo command.
  • tee : The output of the vi/vim write command is redirected using tee.
  • % : Triggers the use of the current filename.

Simply put, the ‘tee’ command is run as sudo and follows the vi/vim command on the current filename given.

 

 

ref: 

转载地址:http://nlxcl.baihongyu.com/

你可能感兴趣的文章
C++ 打开exe文件的方法(VS2008)
查看>>
Windows服务安装后自动启动
查看>>
IGT中国
查看>>
Android消息循环分析
查看>>
11. 系统状态管理
查看>>
Java:java+内存分配及变量存储位置的区别
查看>>
PHP 字符串编码的转换
查看>>
往文件中按行写入数据
查看>>
20. Screen
查看>>
整个站点默认禁用 Session,而某个页面不禁用的做法。
查看>>
ios实例开发精品源码文章推荐(8.22)
查看>>
ElasticSearch 应用场景
查看>>
《数据库技术基础与应用(第2版)》学习笔记——第1章
查看>>
Tomcat性能调优方案
查看>>
Ubuntu12.04上编译PlateGatewayQt
查看>>
(转)UITableView使用详解 相当详细,不错的东东
查看>>
Java中JDK,JRE和JVM之间的关系
查看>>
Python-NLTK环境搭建
查看>>
linux下的usb抓包方法【转】
查看>>
二叉搜索树转换成有序的双向链表
查看>>