CLI with history of commands

I would really like to see a history fo commands one used in CLI (same like in CMD in windows, where if you press the arrows, you brows through the last commands. For example, if I do a long command line and make a mistake, so I would not have to write it again : section>div>p+div>img+div>div+h2^3*4 ...if I want to change the ^3 to ^1 ... or the 4 to 6. Instead of writing it all down, just press arrow key and have the "command" displayed again for editing.