How to run a script after user authentication in Linux

I have a script that I want to run immediately after user authentication. For this, I added the name of the script to the file /etc/rc5.d/S##rc.local. But later I found out that everything that is added to the rc.local file is executed at boot time not after login authentication. Can someone tell me how to run the script after user authentication after login?

+5
source share
2 answers

Alternatively, you can add your script folder to /etc/profile.d.

Read more about it here and here .

, script .sh, .

+13

/etc/pam.d/login:

session optional pam_exec.so /bin/bash /path/to/your/script.sh

script, ( , ).

+3

All Articles