Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

share|improve this question
add comment

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
share|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
add comment

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.

share|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
add comment

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.
share|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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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