让linux的history记录时间 ip 用户等
分类:运用配置
1945
修改一下,使这个日志能记录 时间 ip 用户等。
追加
使生效
效果
vim /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}] "
使生效
source /etc/profile
效果
history
988 2017-12-07 13:23:22[192.168.0.2] cd /usr
989 2017-12-07 13:23:22[192.168.0.2] ls
990 2017-12-07 13:23:22[192.168.0.2] cd local