Get your server issues fixed by our experts for a price starting at just 25 USD/Hour. Click here to register and open a ticket with us now!

Author Topic: Temporarily disable history for a Linux session  (Read 4248 times)

0 Members and 1 Guest are viewing this topic.

Jithin

  • Guest
Temporarily disable history for a Linux session
« 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.
« Last Edit: November 10, 2013, 10:09:25 pm by Jithin »