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?

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


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


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:


# replace "cooluser" with the name of the user you want to change the behavior of the up arrow for.

You have to log out and log back in for the changes to take effect.

Leave a comment

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