jump to navigation

Save shell command history effectively September 18, 2005

Posted by Carthik in commands, guides, ubuntu.
trackback

You should know as a beginning linux user that at the terminal you can press the up arrow to visit the previous commands that you have executed. The bash shell by default saves the last 500 commands (or fewer, if there aren’t that many to save), for easy recall.

However, by default, bash overwrites the history file when you close a session, or a terminal window, saving only those commands that were used in the last session. This can be annoying if, for example you have one terminal window open, and then you open another one, and close the new one after a few commands.

By adding the following line to ~/.bashrc , you can ask bash to append to the history file, thus preventing the overwriting:
shopt -s histappend

I find this pretty useful since I have discovered it.

You can find a detailed explanation of what I tried to say above, with pictures 😉 at the Power Shell Usage guide. You will also find a lot of other useful tips.

Comments»

1. Aldo - September 18, 2005

Thank you 🙂
As a linux noob, this could be useful.

2. robotgeek - September 20, 2005

This link was awesome!

3. pavan - August 2, 2007

very good yar thanx alot

4. Abhi - October 17, 2007

also you can set how many you want to save, its no limit of 500
set history=1000 will save 1000

5. Ferdil - May 25, 2008

This is one of the most useful things I have learned about Ubuntu. Thank you very much.

6. insurance liability - October 19, 2008

insurance liability…

Donner:refugee suction …

7. Clyde - February 13, 2009

Is there an equivalent for this in cshell? This is really handy… but I wish this worked in cshell too.

8. seks izle - September 29, 2010

This link was awesome!


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: