how to set environment variable for root user

Ickhyun Kwon picture Ickhyun Kwon · Mar 9, 2011 · Viewed 33.1k times · Source

I'm Mac user.

I want to set PYTHONPATH env for root. so

$ sudo su -
# vi ~/.profile

and add to file 'export PYTHONPATH=/mypythonlib'

then

# env

I can see this line

PYTHONPATH=/Users/simpnet2/projects/meiji/src/hershey

but..

when I use sudo command, cannot find that

$ sudo env

.. there's no PYTHONPATH

My program has to run with sudo command and needs PYTHONPATH.

Answer

Tabitha picture Tabitha · Mar 9, 2011

If you use sh try /etc/profile, bash try /etc/bashrc and if you use zsh try /etc/zshenv.