I have a script which I want to run just after user log-in authentication. To accomplish this, I added the script name in /etc/rc5.d/S##rc.local
file. But later i got to know that, anything that is added in rc.local file gets executed in boot time of the system not after the login authentication. Can anyone tell me how to run the script after user login authentication?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Alternatively, you can add your script to /etc/profile.d
folder.
More reading about this here and here.
Basically, you should give your script the extension .sh as all these files are executed in a loop after user logs on.
回答2:
Try adding this to your /etc/pam.d/login
:
session optional pam_exec.so /bin/bash /path/to/your/script.sh
You will need to check in your script if the current user is actually an administrator (according to whatever your criteria for being administrator are).