Query Regarding file permissions.

Ian Ward Comfort icomfort at rescomp.stanford.edu
Thu May 10 13:17:57 UTC 2007


On May 10, 2007, at 3:59 AM, Ravi R.S wrote:
> When I execute the following command
>
> "sudo cat .schedule.out >> /var/spool/cron/root.txt"
>
> I am getting error as "/var/spool/cron/root.txt: Permission denied"
>
> But how can I make it to write as a "non root user".

The redirection (">> /var/spool/cron/root.txt") is processed by your  
shell before the shell invokes sudo.  Since your shell is an  
unprivileged process, it fails to open /var/spool/cron/root.txt for  
appending.  You have to:

	sudo sh -c 'cat .schedule.out >> /var/spool/cron/root.txt'

or the like, so that a privileged sh process performs the redirection.

---IWC




More information about the redhat-list mailing list