Skip to main content

Redirection permission problems when using sudo

Redirection is not handled by sudo and the shell does not (always) have the permission required in a redirection. So, using this as a guide,

sudo sh -c 'ls -hal /root > /root/test.out'

or

sudo bash -c '{ command1 arg; command2 arg; } > /output_log'