File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+ # # Collect Root Commands History
3
+
4
+ # Mailing List
5
+ MAILLIST=" YOUREMAIL@DOMAIN"
6
+
7
+ # Log path
8
+ AUDLOG=" /rootcommands"
9
+
10
+ cp /root/.bash_history /tmp/history
11
+ sed -i ' s/#//g' /tmp/history
12
+ for i in ` cat /tmp/history | grep ^[0-9]`
13
+ do
14
+ CONVT=` date -d @$i `
15
+ sed -i " s/$i /$CONVT /g" /tmp/history
16
+ done
17
+
18
+ sed -i ' N;s/\n/ /' /tmp/history
19
+ sleep 10
20
+
21
+ /bin/touch ${AUDLOG} $HOSTNAME -root-hist.log.` date +%h%d%y`
22
+ /bin/grep " $DATE " /tmp/history > ${AUDLOG} $HOSTNAME -root-hist.log.` date +%h%d%y`
23
+ /bin/chmod 0440 ${AUDLOG} $HOSTNAME -root-hist.log.` date +%h%d%y`
24
+
25
+ # Mail notification
26
+ /bin/cat ${AUDLOG} $HOSTNAME -root-hist.log.` date +%h%d%y` | mail -s " HOST: $HOSTNAME - ` whoami` Daily root Commands Log" ${MAILLIST}
You can’t perform that action at this time.
0 commit comments