How do you run the previous command in emacs shell?

Solution 1:

M-p does the job

Solution 2:

In addition to M-p, you can also use C-up, which I find preferable. The complementary keys M-n or C-down will get you the next command in history.