linux history里边显示命令执行显示登陆人登陆时间登录的ip

1. 在linux bash执行:

# if ! grep "HISTTIMEFORMAT" /etc/profile >/dev/null 2>&1; then echo '

UserIP=$(who -u am i | cut -d"("  -f 2 | sed -e "s/[()]//g")

export HISTTIMEFORMAT="[%F %T] [`whoami`] [${UserIP}] " ' >> /etc/profile; fi


2. 再执行:

# source /etc/profile

3.测试

可以看到历史名利里边有执行时间、执行人、执行的命令


linux history里边显示命令执行显示登陆人登陆时间登录的ip_第1张图片

你可能感兴趣的:(linux history里边显示命令执行显示登陆人登陆时间登录的ip)