vi编辑只读文档无法保存解决方法(转载)
2015-08-15 15:14
453 查看
使用普通用户编辑nginx.conf 等配置文件:
保存的时 候会提示:没有Root Permission
可以用如下方法解决:
保存时加上:
:w !sudo tee %
我这里 有一个问题。没有配置sudo权限。
用sudo时提示"xxx is not in the sudoers file. This incident will be reported.其中XXX是你的用户名,也就是你的用户名没有权限使用sudo,我们只要修改一下/etc/sudoers文件就行了。下面是修改方 法:
1)进入超级用户模式。也就是输入"su -",系统会让你输入超级用户密码,输入密码后就进入了超级用户模式。(当然,你也可以直接用root用)
2)添加文件的写权限。也就是输入命 令"chmod u+w /etc/sudoers"。
3)编辑/etc/sudoers文件。也就是输入命令"vim /etc/sudoers",输入"i"进入编辑模式,找到这一 行:"root ALL=(ALL) ALL"在起下面添加"xxx ALL=(ALL) ALL"(这里的xxx是你的用户名),然后保存(就是先按一 下Esc键,然后输入":wq")退出。
4)撤销文件的写 权限。也就是输入命令"chmod u-w /etc/sudoers"。
再次保存:
查看是否 成功:
$ grep sudo nginx.conf
#test :w !sudo tee %
参 考:http://www.cyberciti.biz/faq/vim-vi-text-editor-save-file-without- root-permission/
本文出自 “seven” 博客,请务必保留此出处http://liuyu.blog.51cto.com/183345/303972
保存的时 候会提示:没有Root Permission
可以用如下方法解决:
保存时加上:
:w !sudo tee %
我这里 有一个问题。没有配置sudo权限。
用sudo时提示"xxx is not in the sudoers file. This incident will be reported.其中XXX是你的用户名,也就是你的用户名没有权限使用sudo,我们只要修改一下/etc/sudoers文件就行了。下面是修改方 法:
1)进入超级用户模式。也就是输入"su -",系统会让你输入超级用户密码,输入密码后就进入了超级用户模式。(当然,你也可以直接用root用)
2)添加文件的写权限。也就是输入命 令"chmod u+w /etc/sudoers"。
3)编辑/etc/sudoers文件。也就是输入命令"vim /etc/sudoers",输入"i"进入编辑模式,找到这一 行:"root ALL=(ALL) ALL"在起下面添加"xxx ALL=(ALL) ALL"(这里的xxx是你的用户名),然后保存(就是先按一 下Esc键,然后输入":wq")退出。
4)撤销文件的写 权限。也就是输入命令"chmod u-w /etc/sudoers"。
再次保存:
查看是否 成功:
$ grep sudo nginx.conf
#test :w !sudo tee %
参 考:http://www.cyberciti.biz/faq/vim-vi-text-editor-save-file-without- root-permission/
本文出自 “seven” 博客,请务必保留此出处http://liuyu.blog.51cto.com/183345/303972
相关文章推荐
- jetty maven工程开启jetty调试
- 数据测试读取和传输问题
- 【BAOJ2456】【mode】【坑题】
- 图论500题
- 正则表达式
- Grunt使用记录
- HDU Train Problem II (卡特兰数+大数)
- mvn(即maven)、ant、svn、cvs、git
- Queue (周赛3)
- manacher算法
- 当js中出现 a() is not a function
- 应用中的算法使用
- dos2unix dos文本转换为linux文本 /bin/bas^M:bad interpreter
- 8.String to Integer (atoi)
- 分布式与集群的联系与区别
- 修改linux系统默认启动级别
- hdu 1588
- oracle创建user具体指示
- 一套完整系统对人生的意义
- 黑马程序员----包(package)