Find the answer to your Linux question:
Results 1 to 6 of 6
hey, i tried several times to set permanent environment variable but i failed. everything i did was temp. can anyone tell me how can set permanent env-var?...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Oct 2005
    Posts
    5

    set environment variable


    hey, i tried several times to set permanent environment variable but i failed. everything i did was temp. can anyone tell me how can set permanent env-var?

  2. #2
    Just Joined!
    Join Date
    Nov 2005
    Location
    Somewhere inside my hard drive...
    Posts
    24

    Re: set environment variable

    Quote Originally Posted by y2keyank
    hey, i tried several times to set permanent environment variable but i failed. everything i did was temp. can anyone tell me how can set permanent env-var?
    Try doing it from command line while logged in as root. BTW, what distro are you using?

  3. #3
    Linux Guru Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,252
    Nope.

    Let's say that I want an environment variable called $HELLO, and it contains the value "Hola". I would do this by adding the following line to the ~/.bashrc file:
    Code:
    HELLO=Hola
    Basically, add them to ~/.bashrc, and they take effect whenever you login as that user.

    To make systemwide changes, do the same thing, but to the /etc/profile file.

  4. #4
    Linux Enthusiast puntmuts's Avatar
    Join Date
    Dec 2004
    Location
    Republic Banana
    Posts
    562
    Slackware used to have a profile directory somewhere in /etc. I assume that didn change. You can add scripts setting environment variables there. Those will be executed during boot.
    I\'m so tired .....
    #200472

  5. #5
    Just Joined!
    Join Date
    Oct 2005
    Posts
    5
    hey Cabhan,
    i already know this but the problem is i don't know which part of the file should have this line?
    (e.g) this is my ~/.bashrc
    --------------------------------------------------
    # .bashrc

    # User specific aliases and functions

    alias rm='rm -i'
    alias cp='cp -i'
    alias mv='mv -i'

    # Source global definitions
    if [ -f /etc/bashrc ]; then
    . /etc/bashrc
    fi
    -----------------------------------------------

  6. #6
    Linux Guru Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,252
    Code:
    # .bashrc
    
    # User specific aliases and functions
    
    alias rm='rm -i'
    alias cp='cp -i'
    alias mv='mv -i'
    
    # Source global definitions
    if [ -f /etc/bashrc ]; then
    . /etc/bashrc
    fi
    
    HELLO=Hola
    Just add 'em right to the end.

Posting Permissions

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