LoginSignup
0
1

More than 3 years have passed since last update.

[teeコマンド]一般ユーザーでroot権限が必要なファイルを書き換える時のコマンド

Posted at

状況

書き込み権限のないユーザーでファイルをvimで書き換えようとして。

Can't open file for writing
Press ENTER or type command to continue

と怒られる。

rootユーザーに切り替えて編集し直しても良いんだけど。
という時。

コマンド

:w !sudo tee %

:w! (内容を保存)
sudo tee (rootユーザーで結果の出力をファイルに書き込む)
% (現在読み込まれているバッファのファイルへのパス)

※sudo可能なユーザであること前提

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1