In Ubuntu , whenever we type command on the bash , it gets stored to the history.
When we want to reuse the same command which was used earlier, either you can press UP button several times to get to the command or Use the command search utility.
In order to get to the command search utility just press "Cntrl-R" combination, it will take you to a prompt which looks similar to this:
Just type in few letters of the command , it will auto display the rest. The search displays the most relevant command , so keep the keywords for your command in your mind. When finished just press Enter to execute the command.