Instant replay: Debugging C and C++ programs with rr
  sudo sh -c 'echo 1 >/proc/sys/kernel/perf_event_paranoid'

Here’s another way of doing this:  echo 1 | sudo tee /proc/sys/kernel/perf_event_paranoid

You can’t use > redirection to a different user, because that’s just a file descriptor and they don’t have a user associated with them; but pipes can run between different users like this (well, I guess it’s sudo handling the plumbing there), and so tee can run as root, receiving input from an unprivileged user and then doing what it does, writing the contents of stdin both to a file and to stdout.This leads to a particularly useful trick in Vim if you edit a file you don’t have permission to write (most likely because you forgot to run `sudo vim` but now you’ve made the changes and you just want to save it, not quit and do it again as root):  :w !sudo tee %

That is: “write the contents of this buffer to the stdin of a `sudo tee ‹buffer filename›` invocation”. (See also https://stackoverflow.com/questions/2600783/how-does-the-vim... for more detailed explanation.)