共计 572 个字符,预计需要花费 2 分钟才能阅读完成。
将下面这段内容添加在/etc/profile文件末尾,执行source /etc/profile使之生效。
HISTSIZE=1000
HISTTIMEFORMAT="%Y/%m/%d %T ";export HISTTIMEFORMAT
export HISTORY_FILE=/var/log/audit.log
export PROMPT_COMMAND='{ thisHistID=`history 1|awk "{print \\$1}"`;lastCommand=`history 1| awk "{\\$1=\"\" ;print}"`;user=`id -un`;whoStr=(`who -u am i`);realUser=${whoStr[0]};logMonth=${whoStr[2]};logDay=${whoStr[3]};pid=${whoStr[6]};ip=${whoStr[7]};if [ ${thisHistID}x != ${lastHistID}x ];then echo -E `date "+%Y/%m/%d %H:%M:%S"` $user\($realUser\)@$ip[IP:$pid][LOGIN:$logMonth $logDay] --- $lastCommand ;lastHistID=$thisHistID;fi; } >> $HISTORY_FILE'
正文完