Sample Header Ad - 728x90

How to run a command that involves redirecting or piping with sudo?

138 votes
6 answers
124123 views
I am trying to follow what I assume is best practices of using sudo instead of root account. I am running a simple concat file operation such as: sudo echo 'clock_hctosys="YES"' >> /etc/conf.d/hwclock This fails as to the right of the ">>" it is running as the normal user. Adding extra sudos also fails (expected behaviour since piping to the sudo command and not to the file). Example is just that but it has been verified and tested under the root account.
Asked by DarkSheep (1966 rep)
Dec 26, 2013, 12:41 PM
Last activity: Jan 25, 2025, 09:37 AM