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

前端 未结 15 1594
情深已故
情深已故 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:50

    How about writing a script?

    Filename: myscript

    #!/bin/sh
    
    /bin/ls -lah /root > /root/test.out
    
    # end script
    

    Then use sudo to run the script:

    sudo ./myscript
    

提交回复
热议问题