Find the answer to your Linux question:
Results 1 to 3 of 3
Like Tree1Likes
  • 1 Post By daark.child
Hi All, is there a way to make environment variables permanent? Every time I switch between root and my username, the environment variables I set using export command under my ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jun 2013
    Posts
    16

    Environment variables not saving


    Hi All,

    is there a way to make environment variables permanent? Every time I switch between root and my username, the environment variables I set using export command under my username does not save. Am I using the incorrect command or that's just how it is in Linux. Kinda new to Linux.

    I was thinking I could perhaps edit a configuration file that contains all environment variables. Would this be possible?

  2. #2
    Blackfooted Penguin daark.child's Avatar
    Join Date
    Apr 2006
    Location
    West Yorks
    Posts
    4,393
    Depending on what the variables are, you can set them globally in /etc/profile or create a script in /etc/profile.d. The files you need to edit may be slightly different depending on the distribution that you are using. When you set variables in one user account, they are just set for that user, and not available to other users because their accounts are separate from yours, so what you do in your account does not affect other accounts.
    vindal0012 likes this.

  3. #3
    Just Joined!
    Join Date
    Jun 2013
    Posts
    16
    Quote Originally Posted by daark.child View Post
    Depending on what the variables are, you can set them globally in /etc/profile or create a script in /etc/profile.d. The files you need to edit may be slightly different depending on the distribution that you are using. When you set variables in one user account, they are just set for that user, and not available to other users because their accounts are separate from yours, so what you do in your account does not affect other accounts.
    Hi, thanks for your reply. I am using Oracle Enterprise Linux 6.4 and I am setting variables to point to file directories such as ORACLE_HOME and LD_LIBRARY_PATH. It's more on telling the OS where to find those files it need to run a program. Here's the problem I have, let's say I have a username user1. I set the environmental variables for user1. I then switch to root to do some admin task. When I switch back to user1, all the environment variables are gone. Do you think I should set the file in /etc? It gets frustrating to keep on setting the variables again and again

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •