Modern UNIX shells like bash (default on Linux) and zsh (default on macOS) keep a history of all the commands you enter. The easiest way to access this history is by pressing the up and down cursor keys to browse through the last commands.
But this is only the tip of the iceberg. There are many more powerful history features that are easy to overlook. Learning them and making them second nature will help you to become much faster with a shell.
Viewing the History
The full history can be printed with the history command:
$ history
100 cd
101 vim file.txt
102 ls
103 mount
104 cat /etc/fstab
$
