I would like to recover Linux terminal command history behaviour after updating from Ubuntu 10.04 to 11.10.

I lost the great terminal feature of accessing recent commands through the up and down arrow keys, or the command history is not being saved anymore.

Can somebody guide how to recover that behaviour?

  • Do you mean that the 'history' command doesn't work anymore? Or that you can't use emacs-style searching (C-S, C-R)? What feature are you missing specifically?
    – Dave
    Dec 4 '11 at 20:57
  • Command history is handled by the shell (probably bash), not by the terminal. Jan 20 '12 at 0:23

If you are using BASH, your history should be stored in in the location that is pointed to by the environment variable HISTFILE. You can view this with "echo $HISTFILE". By default, this should be ~/.bash_history. This is also what will be used if $HISTFILE is not set. If HISTFILE is not set to that location, you can set it with the following:

export HISTFILE=~/.bash_history

The following will reload the history file into your history buffer:

history -r

If this does not resolve your issue, the "HISTORY" section of the bash manpage may give more clues as to why your history is not working as expected.

You may also want to check and make sure your shell has not changed from bash:

echo $0
  • these command are not helpful which you mentioned.. Everything you asked me to check is already the same like as u asked.. but still not helpful. I tried this command still not help ful "sudo gedit /home/administrator/.bash_history" output is this 'code' cd /etc/default/ nano console-setup exit 'code'
    – Syed Raza
    Dec 11 '11 at 12:55
  • You might also check if the file ~/.bash_history has correct persmission: sudo chmod 777 ~/.bash_history Sep 29 '12 at 0:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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