Just to be clear with all the other answers, !!
is part of the shell history mechanism. I think the issue isn't with sudo, but with your shell, or more specifically your shell when you are root.
It's been a long time since I played with any of the BSDs, but they tend to be more 'traditional' UNIXes, meaning they still use a real Bourne shell (read: not as featured as bash) as root's shell. 'Real' Bourne shell in this case meaning no history mechanism. This is for system recovery reasons.(*)
When you log into root, you can execute a shell with history, either do exec /bin/bash
or exec /bin/tcsh
as you wish.
The old trick used to be to have a root equiv account, usually called 'toor' which had a tcsh or bash login shell, same home dir, and uid 0. You wouldn't sudo to root, you'd sudo toor
, and then be in bash. I'm not sure what the new hotness is, maybe
(*) The reason, root's shell is /sbin/sh, and statically linked. Meaning it has the minimum number of dependencies. If your shell is /bin/bash and has library dependencies on /usr, and now /usr is gorked, you have no shell. If your shell is /sbin/sh, then if at least /sbin is mountable, you can do some work.