Bash command log ¸¸µé±â
https://www.ehostidc.co.kr/ (403)https://www.ehostidc.co.kr/cscenter/consulting.php (370)
1) rsyslog 0143; 패Ȗ12;1648; 설치 |
root@localhost:[~]: yum install -y rsyslog rsyslog-doc -y |
2) /etc/profile.d/ 내 스크립트 /196;그 1089;성 |
root@localhost:[~]: vi /etc/profile.d/log.sh #!/bin/bash function history_to_syslog { 160; declare command;remote=`who am i|awk '{print $5}'`;command=`fc -ln -0|sed 's/\t //'` 160; if [ $USER == "root" ];then located="$PWD]#";else located="$PWD]$";fi 160; if [ "$command" != "$old_command" ]; then 160; 160; logger -p local3.notice -t bash -i "history2syslog: $USER$remote:$located $command" 160; fi;old_command=$command } trap history_to_syslog DEBUG |
3) 별도 파1068; 생성1012; 위한 rsyslog 수1221; |
root@localhost:[~]: vi /etc/rsyslog.conf *.info;mail.none;authpriv.none;cron.none;local3.none 160; 160; 160; 160; 160; 160; 160; 160;/var/log/messages local3.notice 160; 160; 160; 160; 160; 160; 160; 160; 160; 160; 160; 160; 160; 160; 160; 160; 160; 160; 160; 160; 160; /var/log/cmd |
4) rsyslog 서비스 1116;시1089; 0143; log 확1064; |
root@localhost:[~]: service rsyslog restart root@localhost:[~]: tail -f /var/log/cmd |