Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Linux by (9.5k points)

Below is my command on shell(1):

$ 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

Below is my command on shell(2): 

$ history

 .

 .

 .

 8720  exit

 8721  clear

 8722  history

It shows only the executed results of shell(1). I want to see the history executed by shell(1) as well. Can anyone tell me how to see all the bash history? 

1 Answer

0 votes
by (19.7k points)

You can use 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.

 Interested in Linux? Check out this Linux Certification by Intellipaat.  

Related questions

0 votes
1 answer
0 votes
1 answer
asked Feb 12, 2021 in Linux by sheela_singh (9.5k points)

Browse Categories

...