Sending an Email when a User Logs in

This is short and sweet. Say you want to get an email message anytime someone logs in to a user account on your server. Simply install the mailx package (yum install mailx), and then edit the user’s .bash_profile file in their home directory, adding the following line:


Obviously replace the variables with whatever you want for the sender’s address, subject line, and destination email address. Lastly, create a file in the user’s home dir called .email.msg (don’t forget the preceding period which will make it hidden). The contents of this file will be the body of your email message.

Short, sweet, and makes paranoid people like me very happy.


  1. you spy, you. You’re gonna be NSA any minute… Don’t go Snowden on me. :-)

Leave a Reply

Your email address will not be published. Required fields are marked *

six × = 18

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>