LoginSignup
11
11

More than 5 years have passed since last update.

ログインユーザーの環境変数のままsudoする

Posted at

動機

  • sudoで動かしたいコマンドがあったが、そのコマンド内で環境変数を参照する。
  • しかし、rootユーザーでは参照する環境変数がセットされていない(ログインユーザーの環境変数にのみ存在する)

解決策

大きく分けてふたつある

  • どうにかしてrootユーザーの環境変数にもログインユーザーと同じものをセットする
  • ログインユーザーの環境変数を一時的に使ってsudoする

今回は後者の方法を取った
やり方は簡単で

login-user$ sudo -E command

そう、 -E をつけるだけです。

11
11
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
11
11