User Login Notification

::::Login Notification When User Logged into the Linux Machine:::::

  1. Login into the Linux machine using root.
  2. In home path of root edit .bashrc file  vi .bashrc
  3. Add below Lines
  • echo "ALERT - Root Shell Accessed on:" `date` `who` | mail -s "Alert: Root shell Accessed on `hostname`" <YOUR EMAIL ID>
Save above file.

If you want to add for all the users when you install a Linux server freshly go to /etc/skel

# cd /etc/skel
# vi .bashrc
echo "ALERT - User `who` Logan on:" `date` `who` | mail -s "Alert: User `who am i` logged on to `hostname`"

Save and exit

when you create a new user this files will copy to his home directory and when he logged into the machine it will send you a alert.