Wednesday, January 5, 2011

sudo and cat

Have you ever wanted to cat something and redirect it to another file but received the error or "Permission denied?" Apparently it is due to the fact that sudo is only applied to the first part of the redirection and not the the file you want to redirect it to.

For example:

$ sudo cat /etc/passwd > /etc/passwd1
-bash: /etc/passwd1: Permission denied

I have found a forum post that gives an explanation and a fix:

http://www.linuxquestions.org/questions/linux-software-2/sudo-and-permission-denied-651619/#post3194983

posts #2 and #3

No comments:

Post a Comment