I just learned that Linux has a
sudo !! command which literally applies
sudo to the last entered command. I had never heard about it.
Is that a common control? Where can I find documentation about it?
This is just bash shortcuts. It's not
Take a look at the "History Expansion" section of the bash man page:
This separation of functionality is one of the most beautiful design principles making Linux/Unix so much more powerful than other alternatives where each program is a separate independent island of conventions and capabilities.
"make each program do one thing, and do it well"
Rather than implementing !! inside sudo (or any other command) which can benefit from repeating the previous command -- it is implemented once (in the shells) and all commands can benefit from it. So you can do:
and so on.
But it doesn't end here. The shell does much more than expanding history via the ! event designators. Before executing your command, it does variable expansion, file-name wildcard expansion (globbing), command substitution, file/IO redirection, and much more. All of which can be leveraged and used in any command that's being invoked from the shell.
Another big advantage is that if you spend some time learning your shell ('man bash' in this case) you need to learn it once and you can use these powerful capabilities everywhere, all the time. It is much easier to learn one set of powerful principles and conventions, rather than relearn how command line agrs are handled in each program or utility.