linux记录history日志方法

时间:2026-02-15 18:04:32

1、操作系统版本、内核版本

linux记录history日志方法

2、切换到root用户下,编辑/etc/profile

linux记录history日志方法

3、增加如下内容

##登录账号操作审计

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="[%Y.%m.%d %H:%M:%S]"

chmod 666 $HISTDIR/* 2>/dev/null

                                 

linux记录history日志方法

4、source /etc/profile

linux记录history日志方法

5、cd /var/log/history

linux记录history日志方法

6、会把操作记录按照用户来进行统计

linux记录history日志方法

7、查看操作日志

linux记录history日志方法

© 2026 海能知识库
信息来自网络 所有数据仅供参考
有疑问请联系站长 site.kefu@gmail.com