For those looking for a way to set persistent custom system and user variables, here are some guidelines for doing so in openSUSE and SLES / SLED.
Other Linux distributions follow a similar approach but the filenames can differ.
NOTE: Export is a command to be used to set your desired setting. Entering ' export ' on the command line will show you the environment variables that have been set. ' env ' will give you a complete list of your environment parameters.
Where and what to place?
Both profile and bashrc are files that can be used to set desired environment settings. These files can be found under /etc (profile.local, bash.bashrc.local) and in every users home directory (.profile, .bashrc).
Generally .profile & profile.local should be used for those settings that should be set at startup and logon.
Unlike the profile files, the bashrc* is read every time a shell is started.
Using the files in /etc are to set the values system wide. As you already guessed.. the files in the user home directory are only applied to that specific user.
NOTE: /etc/profile can also be used to include programs to run at startup.
Setting a persistent environment per user:
In the case of wanting to set parameters for one specific user, the .bash_rc in the users home directory is preferred. It will be read each time a bash shell is started. No need to login/logout.
Setting a system wide persistent environment
openSUSE and SLES use the profile.local & bash.bashrc.local. If these files don't exist on your system just create them and add the needed parameters.
Typically the profile.local is preferred. Using the profile.local assures your custom settings are maintained when updating your system (as the profile file can be overwritten by an update).
Examples:
- To add a custom system wide Java home path, add the following to the /etc/profile.local:
#Setting JAVA_HOME
export JAVA_HOME=/usr/java/[path...]
- To add needed path vars after installing eDirectory
#Expanding the system search path for ndspath
export PATH=$PATH:/opt/novell/eDirectory/bin:/opt/novell/eDirectory/sbin
- To add a custom entry for one user, add the following to /home/[user]/.bashrc (or .profile):
#adding sbin to path
export PATH=$PATH:/sbin
* These examples are valid when using the default BASH shell.
If using another shell you might need to adjust the commands appropriately.
