Sink

沉舟侧畔千帆过

  • 主页
  • 归档
  • 书籍
  • 书签
  • 技能树
  • 工具箱
  • LeetCode
  • 关于我
所有文章 友情链接 +1s

  • 主页
  • 归档
  • 书籍
  • 书签
  • 技能树
  • 工具箱
  • LeetCode
  • 关于我

Vim非root权限保存文件

Published on 2015 / 12 / 04

经常作为普通用户权限在服务器上,改一个文件,弄完之后保存发现Permission Deny。以前我都是傻乎乎的强行退出,然后在用root登录修改。其实一条命令就可以解决。

1
:w !sudo tee %
  • :w - Write a file.
  • !sudo - Call shell sudo command.
  • tee - The output of write (vim :w) command redirected using tee. The % is nothing but current file name i.e. /etc/apache2/conf.d/mediawiki.conf. In other words tee command is run as root and it takes standard input and write it to a file represented by %.

只要按L重载文件,就能看见之前的修改已经保存。比之前不保存退出再重进改方便很多,强烈推荐。

Reference: HowTo: Save A File In Vim / Vi Without Root Permission

赏

很惭愧,就做了一点微小的工作

支付宝
微信
读书笔记:Redis入门指南(第2版)
Ubuntu 14.04 上搭建 OpenVPN 服务器
Copyrights © 2009 - 2025 Sink. All Rights Reserved.
Hexo Illya
  • 所有文章
  • 友情链接
  • +1s

tag:

  • ubuntu
  • dns
  • deepin
  • rfc
  • django
  • database
  • work
  • python
  • greenplum
  • postgres
  • how-to
  • linux
  • react
  • firefox
  • nginx
  • vijos
  • go
  • toml
  • tools
  • usaco
  • IPv6
  • gpg

    缺失模块。
    1、请确保node版本大于6.2
    2、在博客根目录(注意不是yilia根目录)执行以下命令:
    npm i hexo-generator-json-content --save

    3、在根目录_config.yml里添加配置:

      jsonContent:
        meta: false
        pages: false
        posts:
          title: true
          date: true
          path: true
          text: false
          raw: false
          content: false
          slug: false
          updated: false
          comments: false
          link: false
          permalink: false
          excerpt: false
          categories: false
          tags: true
    

  • 浮云计算
  • 成成个人学习小站
  • Victor 的自留地
  • amtoaer
  • lxkaka
  • 酷壳CooShell
  • 曜彤.手记

一个人的命运啊,当然要靠自我奋斗,但是也要考虑到历史的行程。

很惭愧,就做了一点微小的工作,谢谢大家。