Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I installed Ubuntu 10.10 yesterday. Then while using the terminal I noticed that once I quit a terminal session its history is gone, although history exists for applications in terminal like-ROOT(CERN) history.

In giving the command

echo $HISTFILESIZE 

it shows 2000. I changed that to 10000 when I quit the session and opened a new terminal; it again shows history as 2000 and no command can be accessed through up/down arrow key.

Please help. I am getting frustrated with soooo.... lot of typing in the terrminal.

share|improve this question
    
What is the output if you type history in terminal? –  Chethan S. May 20 '11 at 9:10

2 Answers 2

If no commands can be run using or that indicates that your history file is empty or you have no read-permissions. Check that.

Maybe you run the commands as another user. If so do:

su otheruser
history 10

and look at the output.

If you change $HISTFILESIZE the changes will be overwritten, whenever you invoke an other shell. To prevent that you should change that variable in your .bashrc. Also you should set the variable $HISTSIZE to a larger value.

Generally usefull tips using histories:

Ctrl+R does a reverse search of your history for you. Alt+. pastes the last argument of the last command into your prompt at cursor position.

Also the bang (!) operator will repeat commands for you in terminal (if it's just about saving you some typing. Example:

confus@confusion:~$ echo "bang + letters will repeat the last command starting with these letters."
bang + letters will repeat the last command starting with these letters.

confus@confusion:~$ clear

confus@confusion:~$ !ech
bang + letters will repeat the last command starting with these letters.

All those histroy related things are stored in the home directory of any user in a file called .bash_history. You can look them up by using the history-command. Her is a small tutorial on howto use history.

confus@confus:~$ history 4 #will print last 4 commands
 1848  ls
 1849  clear
 1850  vi /home/confus/.local/share/applications/nautilus-home.desktop
 1851  history 4

Another very usefull thing is to create a .inputrc file in your home directory with the following content:

"\e\e[C": forward-word
"\e\e[D": backward-word
"\e[A": history-search-backward
"\e[B": history-search-forward

This way you can use the or to complete commands you started to type from history. E.g. when you type a rather lenghty command such as rsync -a -v --human-readable --prune-empty-dirs -e 'ssh -i .ssh/id_rsa' --include="*/" --exclude="snapshot_*" --exclude="restart.*" /scratch/ x@cluster1:/home/x/runs/ and want to run it a second time you can just type rsy and then an it will complete to the last command that started with rsy. Another press of the uparrow will complete to the second-last and so on. I don't know why this isn't the default.

share|improve this answer
    
thaks a lot bro. –  SUMIT GOSWAMI May 21 '11 at 9:21
    
Alt + R? Ctrl + R in my bash. –  Lekensteyn May 21 '11 at 12:07
    
@SUMIT you're welcome. if that answered it, set the ceckmark left of the answer... @Lekensteyn corrected. did too much copy&paste ;) –  con-f-use May 21 '11 at 12:09

You can press Control+R and search through your bash history if you remember a part of the command you entered.

There is also a file called .bash_histroy in your home folder that you can open or grep to find your previously entered commands.

share|improve this answer

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.