Since the suggested command was not typed before, it won't be in the bash history. So Up Arrow or .bash_history will not help.
setting an alias for sudo apt-get install will reduce some typing but you still need to type the name of the program, particularly if the programname is differnt from the package-name.
The simplest way to "type" the command without typing is to copy the line from the terminal and paste it.
- To copy the line, highlight
sudo apt-get install programname using the mouse and press Ctrl+Shift+C.
- To paste, make sure the cursor is at the
$ prompt and press Ctrl+Shift+V.
Hope this help.