Recently, I hit a weird situation where i had use sudo.
I wanted to do the following with privileges
$ sudo echo 1 > /proc/sys/kernel/panic_on_oops
The above is what anyone will try, which didn't work because it sudoes "echo 1"
not the redirection ">"
The solution is
$ sudo sh -c "echo 1 > /proc/sys/kernel/panic_on_oops"
So we create a new sudo shell and -c tells the shell to execute the command mentioned in
the string.
I wanted to do the following with privileges
$ sudo echo 1 > /proc/sys/kernel/panic_on_oops
The above is what anyone will try, which didn't work because it sudoes "echo 1"
not the redirection ">"
The solution is
$ sudo sh -c "echo 1 > /proc/sys/kernel/panic_on_oops"
So we create a new sudo shell and -c tells the shell to execute the command mentioned in
the string.