Dan Widyono on 13 Sep 2007 13:22:37 -0000


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] Bash History question


On Thu, Sep 13, 2007 at 02:00:14PM +0100, Stephen Gran wrote:
> On Thu, Sep 13, 2007 at 08:00:07AM -0400, Mag Gam said:
> > Hello:
> > 
> > Just started to use Linux exclusively, and I have a question pertaining Bash
> > History. I know the history is logged in .bash_history or ($HISTFILE var).
> > My question is, when I fork a new shell ie.
> > $ echo $$
> > 2232
> > $ bash
> > $ echo $$
> > 4434
> > 
> > Where is the history kept for bash.4434? and what happens to the history of
> > bash.2232? How does this work, very confusing to me....

In addition to Stephen's answer regarding the writing of the history, each
shell process holds its own idea of its command history in memory.  As
Stephen mentioned, it isn't written to disk until logout.

Since each process has its own idea of memory (controlled by the virtual
memory management of the kernel), PID2232 will have one idea of the history
"array" while PID4434 will have a separately maintained idea.

HTH as well,
Dan W.
___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug