This happens to me much more than I’d like to admit, so I’m writing about it.

You have a couple of options, the easiest one is to just use !

to tell bash to use the last command.

Add Sudo to Your Last Bash Command With "!!" Syntax