This prompted an informal discussion about habits that would prevent accidental command execution like this. Suggestions raised were using quotes (still executes), never piping to grep (lose a lot of functionality there), and only using part-words (in this case grepping for “reboo”).

Probably the best one I can think of is aliasing dangerous commands like this, e.g:

alias reboot='echo Please use /sbin/reboot or shutdown -r now to reboot this server'

You can the line above to .bashrc for existing users, and updating /etc/skel/.bashrc will make it apply to any future user accounts. The most important one is root (/root/.bashrc or /root/.bash_aliases depending on distro). Ubuntu and Debian separate the aliases out into ~/.bash_aliases (the .bashrc should include this file).

This is what would have happened if our friend had run the same command:

$ dmesg |reboot
Please use /sbin/reboot or shutdown -r now to reboot this server

Similar aliases could be created for halt and poweroff.

Fortunately in this case no damage was done, as the server is part of a load balanced pool!