Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to set environment variable for root user

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.

like image 666
Ickhyun Kwon Avatar asked Mar 09 '11 02:03

Ickhyun Kwon


People also ask

How do I set environment variable in CMD?

2.2 Set/Unset/Change an Environment Variable for the "Current" CMD Session. To set (or change) a environment variable, use command " set varname=value ". There shall be no spaces before and after the '=' sign. To unset an environment variable, use " set varname= ", i.e., set it to an empty string.

What are system root in environment variables?

The %SystemRoot% variable is a special system-wide environment variable found on the Windows NT family of operating systems. Its value is the location of the system directory, including the drive and path.


1 Answers

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

like image 156
Tabitha Avatar answered Oct 27 '22 15:10

Tabitha