use sudo to redirect output in a commandΒΆ

just spawn another shell:

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