Hack 59. Force history not to remember a particular command using HISTCONTROL
by Ramesh
When you execute a command, you can instruct history to ignore the command by setting HISTCONTROL to ignorespace AND typing a space in front of the command as shown below. I can see lot of junior sysadmins getting excited about this, as they can hide a command from the history.
It is good to understand how ignorespace works. But, as a best practice, don’t hide purposefully anything from history.
- # export HISTCONTROL=ignorespace
- # ls –ltr
- # pwd
- # service httpd stop
- [Note: There is a space at the beginning of service, to ignore this command from history]
- # history | tail -3
- 67 ls –ltr
- 68 pwd
- 69 history | tail -3
当前内容版权归 Ramesh Natarajan 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 Ramesh Natarajan .