리눅스 bash history 설정(시간 IP 명령어 등)

Linux history에 날짜,시간,IP,사용자 추가하여 기록하기

HTML Content

Home OS Linux Linux history에 날짜,시간,IP,사용자 추가하여 기록하기

2020년 5월 9일  kimxp

추가전 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