zoukankan      html  css  js  c++  java
  • 查看操作记录小技巧

    1.编辑/etc/bashrc

    if unset PROMPT_COMMAND > /dev/null 2>&1
    then
    declare -r REAL_USER=$(who am i|awk '{print $1}')
    declare -r LOGINTIME=$(date "+%s")
    declare -r HGROUPS=$(groups $USER|awk '{print $NF}')
    export PROMPT_COMMAND='$( command=$(history 1 | { read x y; echo $y; });echo "$HOSTNAME $LOGINTIME user=$REAL_USER@$HGROUPS from=$SSH_CLIENT pwd=$PWD command:$command [$(date "+%Y-%m-%d %T")]">>/var/log/histlog )'
    declare -r PROMPT_COMMAND
    PS1='[u@h W]$ '
    fi
    alias grep='grep --color=auto'
    alias vi='vim'
    HISTTIMEFORMAT="%Y-%m-%d %H:%M:%S "
    HISTFILESIZE=10000
    HISTSIZE=10000
    

    2.source下环境变了

    [root@k8s-matser01 ~]# source /etc/bashrc
    [root@k8s-matser01 ~]# touch /var/log/histlog && chmod 777 /var/log/histlog && chattr +a /var/log/histlog
    [root@k8s-matser01 log]# cat /var/log/histlog
    [root@k8s-matser01 log]# vim /etc/bashrc 
    [root@k8s-matser01 log]# pwd
    /var/log
    [root@k8s-matser01 log]# cat /var/log/histlog
    k8s-matser01 1633929457 user=root@root from=10.1.1.81 7223 22 pwd=/root command:2021-10-11 13:17:37 source /etc/bashrc [2021-10-11 13:17:37]
    k8s-matser01 1633929462 user=root@root from=10.1.1.81 14984 22 pwd=/root command:2021-10-11 13:17:42 source /etc/bashrc [2021-10-11 13:17:42]
    k8s-matser01 1633929462 user=root@root from=10.1.1.81 14984 22 pwd=/root command:2021-10-11 13:17:50 touch 123 [2021-10-11 13:17:50]
    k8s-matser01 1633929457 user=root@root from=10.1.1.81 7223 22 pwd=/var/log command:2021-10-11 13:18:03 cd /var/log/ [2021-10-11 13:18:03]
    k8s-matser01 1633929457 user=root@root from=10.1.1.81 7223 22 pwd=/var/log command:2021-10-11 13:18:05 ls [2021-10-11 13:18:05]
    k8s-matser01 1633929457 user=root@root from=10.1.1.81 7223 22 pwd=/var/log command:2021-10-11 13:18:12 vim histlog [2021-10-11 13:18:22]
    k8s-matser01 1633929457 user=root@root from=10.1.1.81 7223 22 pwd=/var/log command:2021-10-11 13:18:12 vim histlog [2021-10-11 13:22:15]
    k8s-matser01 1633929457 user=root@root from=10.1.1.81 7223 22 pwd=/var/log command:2021-10-11 13:22:18 cat histlog [2021-10-11 13:22:18]
    k8s-matser01 1633929457 user=root@root from=10.1.1.81 7223 22 pwd=/var/log command:2021-10-11 13:24:14 vim /etc/bashrc [2021-10-11 13:25:30]
    k8s-matser01 1633929457 user=root@root from=10.1.1.81 7223 22 pwd=/var/log command:2021-10-11 13:26:22 pwd [2021-10-11 13:26:22]
    
  • 相关阅读:
    Diango基础学习
    Python02-作业(购物车)
    使用spring boot + Thymeleaf实现web小页面
    Python-01作业(登录和三级菜单)
    Java反射机制
    Socket编程
    利用java的url实现小型的网页爬虫
    关于在spring boot里使用Thymeleaf模板的application.properties配置
    Spring
    Spring-bean的自动装配
  • 原文地址:https://www.cnblogs.com/Applogize/p/15392973.html
Copyright © 2011-2022 走看看