You can repeat the last used command by typing “!!”. For example if you typed:
apt upgrade
as non root user, you will get the following message:
error: you cannot perform this operation unless you are root.
But you don’t have to type the whole command again with sudo in front of it, just type:
sudo !!
And it’s doing a:
sudo apt upgrade