General Category > General Discussion

Temporarily disable history for a Linux session

(1/1)

Jithin:
Hi Guys,

Suppose you want to temporarily disable recording history for the current Linux session.

You can do that using set command.

Eg,

jithinp ~ $ history                                                                                                                                                             
   11  clear                                                                                                                                                                     
   12  ls                                                                                                                                                                       
   13  ls -alh                                                                                                                                                                   
   14  free                                                                                                                                                                     
   15  free -m                                                                                                                                                                   
   16  df -i                                                                                                                                                                     
   17  df -h                                                                                                                                                                     
   18  history

Now you can execute the command "set +o history" to disable history.

jithinp ~ $ set +o history

Now execute some other commands and let see if history command is recording it.

jithinp ~ $ vi ln                                                                                                                                                               
jithinp ~ $ vi ips                                                                                                                                                               
jithinp ~ $ cat ips

jithinp ~ $ history                                                                                                                                                             
   11  clear                                                                                                                                                                     
   12  ls                                                                                                                                                                       
   13  ls -alh                                                                                                                                                                   
   14  free                                                                                                                                                                     
   15  free -m                                                                                                                                                                   
   16  df -i                                                                                                                                                                     
   17  df -h                                                                                                                                                                     
   18  history

See, it is not recording anything after we executed "set +o history".

If you want to enable it again, simply execute "set -o history"

Thank you for stopping by.

Navigation

[0] Message Index

Go to full version