linux history记录格式加固

linux history记录格式加固 设置history记录行数

 

#保存一万条命令记录
sed -i 's/^HISTSIZE=1000/HISTSIZE=10000/g' /etc/profile


#在/etc/profile的文件尾部添加如下行数配置信息
######jiagu history xianshi#########
USER_IP=`who -u am i 2>/dev/null | awk '{print $NF}' | sed -e 's/[()]//g'`
if [ "$USER_IP" = "" ]
then
USER_IP=`hostname`
fi
export HISTTIMEFORMAT="%F %T $USER_IP `whoami` "
shopt -s histappend
export PROMPT_COMMAND="history -a"
######### jiagu history xianshi ##########


#启用新的记录命令环境
source /etc/profile

 

效果图:命令行数 日期年月日 小时分秒  IP地址  用户  具体命令

image

 

posted @ 2025-07-25 15:43  昵称昵称昵称  阅读(14)  评论(0)    收藏  举报