First let me show an example below.
In shell(1) I did the following command.
$ ping google.com
PING google.com (74.125.235.164) 56(84) bytes of data.
64 bytes from nrt19s12-in-f4.1e100.net (74.125.235.164): icmp_seq=1 ttl=54 time=2.85 ms
64 bytes from nrt19s12-in-f4.1e100.net (74.125.235.164): icmp_seq=2 ttl=54 time=3.42 ms
And after that, open another shell(2) and look at history.
$ history
.
.
.
8720 exit
8721 clear
8722 history
In this case, the shell can not see the history executed by shell(1), but I want to see all of the bash history in every shell.
So my question is how can I see all of the bash history? Does anybody know how to hack?
Thank you very much in advance!
Searching shell command historyOpen a terminal application on your Linux or Unix and type history to list all commands. To search for a command in the history, press ctrl+r multiple times.
In Bash, your command history is stored in a file ( . bash_history ) in your home directory.
If you're losing bash history and you have multiple sessions at a time, it's because each session is overwriting the other sessions' history. You probably want to tell bash to not overwrite the history each time, but rather to append to it. You can do this by modifying your . bashrc to run shopt -s histappend .
cat ~/.bash_history
would also work, although I tend to just use
vim ~/.bash_history
and then use /
to search
You should look into the histappend
shell option and the -a
flag to history
:
histappend
If set, the history list is appended to the file named by the value of the
HISTFILE
variable when the shell exits, rather than overwriting the file.
history
-a
Append the "new" history lines (history lines entered since the beginning of the current bash session) to the history file.
If you put history -a
into your PROMPT_COMMAND
, you'll get an always-up-to-date .bash_history
file.
try this:
Edit your .bashrc and append this to it's end:
shopt -s histappend
PROMPT_COMMAND="history -n; history -a"
unset HISTFILESIZE
HISTSIZE=2000
source: http://subbass.blogspot.com.br/2009/10/howto-sync-bash-history-between.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With