Certain machines require only periodic root access. This is often the case on shared servers. You can setup an email alert that will immediately notify you that someone has accessed the root account.
Login as root and edit the file, ‘~/.bash_profile’. Near the bottom add this:
echo -e “Subject: Root Access\n\nALERT – Root Shell Access on: `date`, `who`\n” | mail -s "Root access" email@example.com
Now to test it, log out of root and then log back on as root. You should now get an alert that someone has logged in as root. This script shows the time and user. You can adjust the information accordingly depending on how detailed you want it.
ALERT - Root Shell Access on: Tue Jun 30 20:06:40 MDT 2009, nixtutor pts/0 2009-06-30 19:47 (NixTutor)