1.將以下代碼添加到/etc/profile
文件末尾vim
export HISTTIMEFORMAT="%Y-%m-%d %H:%M:%S `whoami` `echo $SSH_CLIENT | awk '{print $1}'` "
2.使用history命令顯示輸出以下:bash
1015 2018-03-26 19:54:42 root 192.168.2.44 ls 1016 2018-03-26 19:58:58 root 192.168.2.44 cd /opt/ 1017 2018-03-26 19:58:59 root 192.168.2.44 ls 1018 2018-03-26 20:27:34 root 192.168.2.44 zkCli.sh 1019 2018-03-27 11:37:15 root 192.168.2.44 history 1020 2018-03-27 11:37:19 root 192.168.2.44 vim /etc/profile 1021 2018-03-27 11:37:44 root 192.168.2.44 source /etc/profile 1022 2018-03-27 11:37:46 root 192.168.2.44 history 1023 2018-03-27 11:38:18 root 192.168.2.44 echo $SSH_CLIENT