"Well why does the entire internet say to use dd then?"
Because you usually need root to write to drives, and you can't `sudo` redirect. `sudo dd if=whatever.img of=/dev/whatever` is nicer and easier than `sudo sh -c "cat whatever.img >/dev/whatever"`.
The reason why sudo wasn't working is that it runs the command with root privileges, but redirecting to a file with > is done through the shell, which is running under your normal user level privileges. If you want to redirect to a file that only root can write to, you can use the tee command. That command will write anything passed to it via stdin to the file given as an arg.
There's one good (?) reason to use dd with devices: it specifies target in the same command. For devices, writing to them usually requires root privileges, so it's easy to:
sudo dd .... of=/dev/...
But there's no trivial cat equivalent:
sudo cat ... > target
Will open target as your current user anyway. You can play around with tee and redirection of course. But that's getting more complicated than the original.
This is all pretty basic stuff. One thing that always bites me is trying to use sudo to redirect to a protected file. This doesn't work, because the shell is doing the redirection, not sudo:
I use dd when redirect doesn't have permission.
reply