1.在/etc/profile的最后添加如下部分:
USER_IP=`who -u am i 2>/dev/null| awk ‘{print $NF}‘|sed -e ‘s/[()]//g‘`
export HISTTIMEFORMAT="[%F %T][`whoami`][${USER_IP}] "
2. source /etc/profile
311 [2013-08-28 14:39:20][root][192.168.80.1] history
312 [2013-08-28 14:39:43][root][192.168.80.1] df -h
313 [2013-08-28 14:39:45][root][192.168.80.1] df -g
314 [2013-08-28 14:39:47][root][192.168.80.1] history
315 [2013-08-28 14:40:01][root][192.168.80.1] ifconfig
316 [2013-08-28 14:44:53][root][192.168.80.1] init 6
317 [2013-08-28 14:46:56][root][192.168.80.1] sdfsdfsd
318 [2013-08-28 14:46:58][root][192.168.80.1] ls
319 [2013-08-28 14:47:02][root][192.168.80.1] hostory
320 [2013-08-28 14:47:04][root][192.168.80.1] history
321 [2013-08-28 14:48:35][root][192.168.80.1] cat /etc/profile
322 [2013-08-28 14:54:32][root][192.168.80.1] history