How do I use sudo to redirect output to a location I don't have permission to write to?

前端 未结 15 1678
情深已故
情深已故 2020-11-22 07:23

I\'ve been given sudo access on one of our development RedHat linux boxes, and I seem to find myself quite often needing to redirect output to a location I don\'t normally h

15条回答
  •  庸人自扰
    2020-11-22 07:55

    The way I would go about this issue is:

    If you need to write/replace the file:

    echo "some text" | sudo tee /path/to/file
    

    If you need to append to the file:

    echo "some text" | sudo tee -a /path/to/file
    

提交回复
热议问题