Admin-Ahead Community

General Category => General Discussion => Topic started by: Jithin on November 01, 2013, 06:10:19 pm

Title: Temporarily disable history for a Linux session
Post by: Jithin on November 01, 2013, 06:10:19 pm
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.