How can I see Bash history from more than one terminal session in Ubuntu?
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Flying Over Ancient Lands
--
Chapters
00:00 How Can I See Bash History From More Than One Terminal Session In Ubuntu?
01:23 Answer 1 Score 8
01:56 Accepted Answer Score 11
02:23 Answer 3 Score 0
03:09 Answer 4 Score 1
03:27 Thank you
--
Full question
https://superuser.com/questions/121195/h...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#ubuntu #commandline #bash #history
#avk47
ACCEPTED ANSWER
Score 11
You can use
history -a
to immediately append the in-memory history to the history file. One terminal session can't see another's unless this is done or the other is exited.
You can use
history 200 | less
to see that number of entries.
In addition to HISTSIZE
see the entry in the Bash man page concerning HISTFILESIZE
.
ANSWER 2
Score 8
Once you log out the history gets appended to the file ~/.bash_history
. Have a look in there.
By default it will remember your last 500 commands. If you want to save more set the variable HISTSIZE
in ~/.bashrc
.
I also do add ignoredups
to HISTCONTROL
(with HISTCONTROL=$HISTCONTROL:ignoredup
). This makes duplicate consecutive commands to be save only once.
Have a look at man 1 bash
for what else you can tune about the history.
ANSWER 3
Score 1
bash history is usually loaded when the shell begins running, and is saved when it is exited normally. You can use history -a
and history -n
to override this, but not automatically unless you abuse $PROMPT_COMMAND
or something similar.
ANSWER 4
Score 0
Sanoj, this really should "just work"; I don't think there is supposed to be anything special you need to do to enable this. It sounds like something is interfering with the normal course of events.
I would look in /etc/profile, /etc/bashrc (or perhaps /etc/bash.bashrc according to some sources), ~/.bash_profile, ~/.bashrc, ~/.bash_login, ~/.bash_logout, to see if there is anything that might be affecting the history (perhaps grep -i hist
on each of the above files).
... In particular I wonder if you have something in ~/.bash_logout that removes the file.
Alternatively, is it possible that something is overriding the $HOME
variable?