linux命令h---history

自古美人都是妖i 提交于 2020-01-26 19:57:06

history命令优化:

有时发现运行中设备重启,但设备被ssh的人较多,无法确定设备是否是被人为的在reboot,通过修改history命令配置可以追查此问题,方便以后运维。可在iraid的镜像里做同样修改。

好处:

a、让历史记录里面带有时间
b、让同一设备所有连接终端命令都记录到history当中去。

效果如下:
在这里插入图片描述
方法:在/etc/bashrc 最后加下下面内容然后再source /etc/bashrc

HISTTIMEFORMAT="%F %T "
export HISTTIMEFORMAT
# Avoid duplicates
export HISTCONTROL=ignoredups:erasedups
# When the shell exits, append to the history file instead of overwriting it
shopt -s histappend

# After each command, append to the history file and reread it
export PROMPT_COMMAND=“KaTeX parse error: Expected '}', got 'EOF' at end of input: …ROMPT_COMMAND:+PROMPT_COMMAND$’\n’}history -a; history -c; history -r”
export HISTSIZE=10000

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!