추가전 history명령을 사용하면 명령수와 명령만 나타납니다.
[root@localhost]# history
1026 history
1027 vim /etc/profile
1028 source /etc/profile
1029 history
/etc/profile 파일을 편집하고 맨 마지막에 아래와 같은 내용을 추가합니다.
[root@localhost]# vim /etc/profile
#history
USER_IP=`who -u am i 2>/dev/null| awk '{print $NF}'|sed -e 's/[()]//g'`
if [ -z $USER_IP ]
then
USER_IP=`hostname`
fi
export HISTTIMEFORMAT="%Y.%m.%d %H:%M:%S ${USER_IP} ${LOGNAME} "
저장하고 source /etc/profile을 실행해 줍니다.
[root@localhost]# source /etc/profile
[root@localhost]# history
1027 2020.05.09 14:37:49 127.0.0.1 root vim /etc/profile
1028 2020.05.09 14:38:14 127.0.0.1 root source /etc/profile
1029 2020.05.09 14:38:16 127.0.0.1 root history
명령수,날짜,시간,IP,사용자,명령순으로 나타납니다.