LoginSignup
0
0

More than 5 years have passed since last update.

書き込み権限のないディレクトリにリダイレクト出力できない場合の対応

Posted at

現象

  • ユーザー書き込み権限のないディレクトリ/exampleを対象として、sudoを用いて以下のコマンドを実行したら権限エラーで書き込めなかった。
sudo ls -al > /example/out.txt
  • どうやらsudoによる権限付与がリダイレクト後のファイル出力には効かないらしい。

対策

以下のコマンドで正常に出力できた。

sudo sh -c 'ls -al > /example/out.txt'
0
0
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
0