操作
编辑文件
gedit /etc/profile
编辑内容
# Add additional information to the "history" command: execution time + executor
USER_IP=`who -u am i 2>/dev/null | awk '{print $NF}' | sed -e 's/[()]//g'`
HISTDIR=/var/log/history
if [ -z $USER_IP ]
then
USER_IP=`hostname`
fi
export HISTSIZE=4096
DT=`date +%Y%m%d_%H%M%S`
export HISTFILE="$HISTDIR / ${LOGNAME}_${USER_IP} $DT"
export HISTTIMEFORMAT="%F %T | $USER_IP:`whoami` | "
chmod 666 $HISTDIR /* 2>/dev/null
执行
source /etc/profile
查看效果
history