Can anyone help me write a shellscript that will will be placed in the profile of a user so that that user will be able to login to the system only once; after that if the user tries again he should be locked out and an email sent to the administrator. Please help me
the following command allows a user to login only once:
# all on one line
[ `w -h -s| cut -d" " -f1 | grep "^$LOGNAME$" | wc -l` -gt 1 ] && exit 0
You should be able to modify it to fit your needs. Since the "w" prints a summary of who is logged into a system, if more than one instance of the user exists, terminate the user's login process.
If it were me, I'd place this in /etc/profile. If you place it in the user's .profile, they can edit it, if said user has command-line access.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.