<p>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 have write access to.</p>

<p>The trouble is, this contrived example doesn't work:</p>

<pre><code>sudo ls -hal /root/ &gt; /root/test.out
</code></pre>

<p>I just receive the response:</p>

<pre><code>-bash: /root/test.out: Permission denied
</code></pre>

<p>How can I get this to work?</p>

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