编辑[环境变量]配置文件
# 打开文件
vi /etc/profile
# 插入下边代码
export PROMPT_COMMAND='{ msg=$(history 1 | { read x y; echo $y; });echo "[euid=$(whoami)]":$(who am i):[`pwd`]#"$msg" >>/tmp/history_cmd.log; }'
创建log文件
touch /tmp/history_cmd.log # 创建log文件
chmod 777 /tmp/history_cmd.log # 设置文件权限
使环境变量生效
source /etc/profile
查看log文件
cat /tmp/history_cmd.log