LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu
User Name
Password
Ubuntu This forum is for the discussion of Ubuntu Linux.

Notices

Reply
 
LinkBack Search this Thread
Old 07-10-2012, 05:34 AM   #1
AlexFr
LQ Newbie
 
Registered: May 2010
Posts: 24

Rep: Reputation: 0
Setting persistent environment variables for root user


To create persistent environment variables, I add the script file to /etc/profile.d directory, for example:
Code:
# my script
export MY_VAR=var_value
This works properly for current user:
Code:
alex@alex-64:~$ echo $MY_VAR
var_value
Now I need the same environment variables for the root user, but /etc/profile.d script doesn't work for root:
Code:
alex@alex-64:~$ echo $MY_VAR
var_value
alex@alex-64:~$ sudo su
root@alex-64:/home/alex# echo $MY_VAR

root@alex-64:/home/alex#
How can I set the same variables for the root?
 
Old 07-10-2012, 05:43 AM   #2
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728
when you issue "su", you take on root privileges, but you keep your user environment. Use "su -" to have the root environment.

Also, I'm not sure when that script runs---for sure at boot time, but when loggin in??
 
1 members found this post helpful.
  


Reply

Tags
environment variable, root


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
setting Environment variables? muby Linux - Newbie 5 10-02-2007 05:21 AM
Setting and getting environment variables??? Sulman Shah Fedora 2 12-13-2006 06:33 PM
Setting Environment Variables farzan Linux - Newbie 2 08-07-2004 09:13 AM
setting environment variables jayjoh Linux - Newbie 9 07-12-2004 12:35 PM
setting environment variables rezza Linux - Distributions 2 04-09-2003 08:21 AM


All times are GMT -5. The time now is 09:28 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration