linux记录history日志方法

2025-10-15 11:38:39

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日志方法

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢