I put some script on my ubuntu linux in /etc/profile.d/myscript.sh but it's just work on my user.
But it's work only user logged in not when I use sudo.
# myscript.sh export MYVAL="HELLO" echo $MYVAL // HELLO sudo echo $MYVAL // ?!
Could you please explain better what are you trying to achieve?
.profile is executed with a user privileges, when the user logs on.
ok, sudo strips environment variables for various security reasons. In order to do what you want, you have to put in /etc/sudoers