[20210618]记录bash shell执行的命令.txt
--//新版本bash shell加入了记录执行命令的功能,仅仅设置syslog_history.简单测试并记录如下:
# echo $BASH_VERSION
4.2.46(2)-release
# shopt syslog_history
syslog_history off
# shopt -s syslog_history
# shopt syslog_history
syslog_history on
--//测试如下:
# pwd
# cd /tmp
Jun 22 08:41:21 xxxx2 -bash: HISTORY: PID=1257 UID=0 shopt syslog_history
Jun 22 08:41:34 xxxx2 -bash: HISTORY: PID=1257 UID=0 pwd
Jun 22 08:41:37 xxxx2 -bash: HISTORY: PID=1257 UID=0 cd /tmp/
Jun 22 08:41:40 xxxx2 systemd-logind: New session 136371 of user root.
Jun 22 08:41:40 xxxx2 systemd: Started Session 136371 of user root.
Jun 22 08:42:38 xxxx2 -bash: HISTORY: PID=1465 UID=0 tail -F /var/log/messages
--//可以将该命令写入/etc/bashrc,这样全部命令在/var/log/messages都会记录下来.
--//另外一个方法使用script,这个可以使用它做一些演示,可以使用scriptreplay回放.
--//参考链接:http://blog.itpub.net/267265/viewspace-1276764/=>[20140922]scriptreplay的使用.txt
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/267265/viewspace-2777710/ ,如需转载,请注明出处,否则将追究法律责任。