Bash Script to Send a Mail When a New User Account is Created in System
======
There are many open source monitoring tools are currently available in market to monitor Linux systems performance.
It will send an email alert when the system reaches the specified threshold limit.
It monitors everything such as CPU utilization, Memory utilization, swap utilization, disk space utilization and much more.
But i don’t think they have an option to monitor a new user creation activity and alert when it’s happening.
If not, it doesn’t really matter as we can write our own bash script to achieve this.
We had added many useful shell scripts in the past. If you want to check those, navigate to the below link.
* **[How to automate day to day activities using shell scripts?][1]**
What the script does? It monitors **`/var/log/secure`**` ` file and alert admin when a new account is created in system.
We can’t run this script frequently since user creation is not happening very often. However, I’m planning to run this script once in a day.
So, that we can get a consolidated report about the user creation.
If useradd string was found in “/var/log/secure” file for yesterday’s date, then the script will send an email alert to given email id with new users details.
**Note:** You need to change the email id instead of ours.