I would like to run a script after a linux user logs in to do some additional security checks. The user should first login normally using their password, but then be checked with my script, and then get full access to the system. Is this possible?
2 Answers
Assuming all your users are using bash, then the file /etc/profile
is executed on login. On some distros there is an /etc/profile.d
. You could drop your login script into this directory.
If you're trying to do this for EVERY user on the system that may log into a bash shell (basically root, and any other "normal" user), then you'll want to add the command into /etc/profile
or add the script into /etc/profile.d/
depending on your system.
If, however, you're trying to do this for a specific user, the place to add it would be into that user's ~/.bash_profile
or ~/.profile
.
See this page for more information on the files, as well as /etc/bashrc
/~/.bashrc