How Do You Get the “Up” Arrow to Show a Previous Command in Linux?

Problem scenario
When you press the up arrow on the keyboard you see " ^[[A". You want to see the previous command that was entered. How do you enable history at the command line?

Solution
Root cause: The /etc/passwd file has an entry like this:

cooluser:x:1001:1002::/home/cooluser:

(This could be caused if you created the user quickly with a useradd command.)

Procedures

Run this command: sudo cat /etc/passwd | grep $(whoami)

Do you see a /bin/bash at the end? If not you need to modify the /etc/passwd file to have a /bin/bash at the end of the stanza for your user having the problem. This is how it should look when you are done:

cooluser:x:1001:1002::/home/cooluser:/bin/bash

Leave a comment

Your email address will not be published. Required fields are marked *