0

The env variables I set are getting reset to the previous values after closing the current instance of the bash console. How to set or unset those variables without getting them reset everytime? I am using OpenSuse 12.3 with bash 4.2

5
  • 1
    Using export to set variables? Sep 13, 2013 at 13:32
  • yes using export
    – scarecrow
    Sep 13, 2013 at 13:54
  • 1
    @SlightlyCuban: export makes environment variables available to child processes. It has nothing to do with persistence and will not help this problem.
    – garyjohn
    Sep 13, 2013 at 13:56
  • @garyjohn thanks for clarifying. what do i do for persistence?
    – scarecrow
    Sep 13, 2013 at 13:58
  • It depends on the distribution, whether you want them visible to programs launched from your window manager, and whether you want them visible to all users or just you. The usual place for just you is ~/.profile, or if you're using bash, ~/.bash_profile. If they only need to be seen by interactive shells and their children, ~/.bashrc will do. To been seen by all users, use /etc/environment, /etc/profile or /etc/bashrc, depending on their scope, your distribution and your shell.
    – garyjohn
    Sep 13, 2013 at 14:46

1 Answer 1

2

export only sets variables for that shell. To make it available to all shells, you'll need to add the variables to ~/.bashrc (for your user account) or to /etc/bashrc (for all accounts on the system): https://marylou.byu.edu/documentation/unix-tutorial/unix9.php

These configuration scripts are called when you first start bash, so any environment variables you define in there would be defined for all shells.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .