Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.
$cat test
export var=value

$source ./test

echo $var

$chmod +x

$echo $var

$sudo ./

I get nothing. I was expecting to see value.

What is going on?

share|improve this question

migrated from Oct 28 '11 at 2:06

This question came from our site for professional and enthusiast programmers.

Does $ ./ (without sudo) shows value ? –  Didier Trosset Oct 27 '11 at 11:55

1 Answer 1

up vote 5 down vote accepted

if you want to keep the environment with a sudo, use sudo -E that will preserve environment.

If you need to always preserve some of your environment variables, edit the sudoers file to add lines :

Defaults        env_reset
share|improve this answer

Your Answer


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.