Simply you can use up arrow key to get last command.
And using exclamatory(!) symbol also you can excecute the commands of previous command(s).
For example I have ran 3 commands
vi /etc/samba/smb.conf -->1st
ping -c5 google.com -->2nd
tail -f /var/log/syslog -->3rd
Now if I again want to open /etc/samba/smb.conf file, just type & hit enter
Using history numbers also you can run any previosly excecuted commands
2024 man dig
2025 nslookup localhost
2026 echo $?
2030 tree -d /etc
2031 vi /etc/samba/smb.conf
2032 ping -c5 google.com
2033 tail -f /var/log/syslog
If you want to run command of history number 2030 just type
Here are some Linux Keyboard Shortcuts