When I connect to my VPS through terminal and I want see the previous commands I get:

$ ^[[A^[[A

(by pressing up arrow)

What is wrong with it ? How can I see unix previous commands instead ?

thanks

link|improve this question

feedback

3 Answers

up vote 5 down vote accepted

You are most likely using sh rather than bash or some other shell that allows command line editing. Try running bash and see what happens. If this fixes things for you then you will need to change the default shell for the account e.g.

usermod -s /bin/bash YourLogin
link|improve this answer
@lain how can I switch shell and use the other one ? – Patrick Nov 3 '10 at 21:40
@lain great thanks – Patrick Nov 3 '10 at 21:46
2  
chsh also works to change the login shell. – Dennis Williamson Nov 3 '10 at 23:45
feedback

There is another pitfall if you have multiple shells open on the same user account: the history finally saved in the .history file will be that of the last shell closed.

link|improve this answer
This is true by default, but not by necessity -- see shopt -s histappend. (Note that bash won't see the history of other instances until history is reloaded, but you can stuff history -a; history -n into your PROMPT_COMMAND.) – jgoldschrafe Nov 4 '10 at 1:58
feedback

Alternatively, you can still use sh vi mode to get the command history:

set -o vi
<ESC> to get in command mode, K to go up the history.
link|improve this answer
I don't think this is a bourne shell feature. I'm not sure. Bash certainly has it, google suggests ksh does too. Solaris sh does not, neither does dash. So I would not rely on it being available in all situations. – jmtd Nov 4 '10 at 13:48
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.