美文网首页
linux history里边显示命令执行显示登陆人登陆时间登录

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

作者: think_lonely | 来源:发表于2019-10-31 09:44 被阅读0次

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里边显示命令执行显示登陆人登陆时间登录

      本文链接:https://www.haomeiwen.com/subject/avyzvctx.html