When are scripts inside etc/profile.d executed?

Solution 1:

Files in /etc/profile.d/ are run when a user logs in (unless you've modified /etc/profile to not do this) and are generally used to set environment variables.