How do you run the previous command in emacs shell?
M-p
does the job
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.
You might also add this to your emacs init file:
(define-key comint-mode-map (kbd "<up>") 'comint-previous-input)
(define-key comint-mode-map (kbd "<down>") 'comint-next-input)