Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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 // ?!
share|improve this question

1 Answer 1

up vote 1 down vote accepted

Could you please explain better what are you trying to achieve? .profile is executed with a user privileges, when the user logs on.
So in order to use sudo in .profile you have to put user/group, user belongs to in /etc/sudoers

ok, sudo strips environment variables for various security reasons. In order to do what you want, you have to put in /etc/sudoers

Defaults        env_reset  
Defaults        env_keep += "MYVARIABLE YETANOTHER"
share|improve this answer
    
i need to define a variable that can i use in each user with and without sudo. it's so simple. –  sweb Nov 5 '12 at 9:04

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.