5
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

sudoしてもリダイレクトで権限のないファイルに書き込めない時の対処法

Posted at
sudo echo 'deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main' > /etc/apt/sources.list.d/pgdg.list

ってしたらzsh: permission denied: /etc/apt/sources.list.d/pgdg.list で書き込めなかったので、その対処法でも。

原因

まあ、見たらわかると思うんですが sudo の効果はリダイレクトまでは有効にならないご様子

対策

色々とあるらしいんですが、一番楽そうだったこれを使うことにしました。

sudo -s 
echo 'deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main' > /etc/apt/sources.list.d/pgdg.list
exit

参考

他の対処法を知りたい方はこちらをどうぞ。
linux - How do I use sudo to redirect output to a location I don't have permission to write to? - Stack Overflow

5
6
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
5
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?