Thursday, 2 February 2012

Linux command line History help

* showing command line history time format
# export HISTTIMEFORMAT='%F %T '

* controlling total number of lines in the shell history
Add the following  lines to the .bash_profile
HISTSIZE=450
HISTFILESIZE=450

* Changing the history file name from .bash_history from any other
Add the following line to the .bash_profile 
# vi ~/.bash_profile
HISTFILE=/root/.my_command

* Eliminate the continuous repeated entry from history
To check this repeat some commands and after that export the following
# export HISTCONTROL=ignoredups

after giving this if you type any comands repeately it shows only once in commandline.

* Erase duplicates across the whole history
# export HISTCONTROL=erasedups 

previous commands will not go, only commands that come after this will have its effect.

* Force history not to remember a particular command
# export HISTCONTROL=ignorespace 

and when you execute a particular command, put a space before the command and that command will not showing in the history.
 

exp:- #  service mysqld stop 
There is a space at the beginning of service,to ignore this command from history. 

* Disable the usage of history
# export HISTSIZE=0
It will not store anything in history

* Ignore specific commands from the history
# export HISTIGNORE="pwd:ls:ls -ltr:"
 

after this history will not record pwd, ls and ls -ltr, we can specify more commands here so .
 
 


  
 

No comments:

Post a Comment