sry didnt read the the middle questione
put that in /etc/bashrc if bash
and /etc/csh.login for tcsh
this applays to all users if you just want i to your self put only in
%HOME%/.bashrc or
%HOME%/.tcshrc
Main Topics
Browse All TopicsHow do you set the PATH, JAVA_HOME or CLASSPATH in Redhat Linux?
I want to know how to set it such that when the OS is booted up, these variables are set. In Windows, this is done in the Control Panel -> System -> Advance -> Environment Variables.
I also want to know how you override the default variables in a particular shell. In Windows, we can do SET PATH=%PATH%;c:\newpath to override the default PATH.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
I am using bash. Should I edit /etc/bashrc or etc/profile?
How do I add the settings in the file? This is how /etc/bashrc looks like:
# /etc/bashrc
# System wide functions and aliases
# Environment stuff goes in /etc/profile
# by default, we want this to get set.
# Even for non-interactive, non-login shells.
if [ "`id -gn`" = "`id -un`" -a `id -u` -gt 99 ]; then
umask 002
else
umask 022
fi
# are we an interactive shell?
if [ "$PS1" ]; then
if [ -x /usr/bin/tput ]; then
if [ "x`tput kbs`" != "x" ]; then # We can't do this with "dumb" terminal
stty erase `tput kbs`
elif [ -x /usr/bin/wc ]; then
if [ "`tput kbs|wc -c `" -gt 0 ]; then # We can't do this with "dumb" terminal
stty erase `tput kbs`
fi
fi
fi
case $TERM in
xterm*)
if [ -e /etc/sysconfig/bash-prompt
PROMPT_COMMAND=/etc/syscon
else
PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME
fi
;;
screen)
if [ -e /etc/sysconfig/bash-prompt
PROMPT_COMMAND=/etc/syscon
else
PROMPT_COMMAND='echo -ne "\033_${USER}@${HOSTNAME%%
fi
;;
*)
[ -e /etc/sysconfig/bash-prompt
;;
esac
# Turn on checkwinsize
shopt -s checkwinsize
[ "$PS1" = "\\s-\\v\\\$ " ] && PS1="[\u@\h \W]\\$ "
if [ "x$SHLVL" != "x1" ]; then # We're not a login shell
for i in /etc/profile.d/*.sh; do
if [ -r "$i" ]; then
. $i
fi
done
fi
fi
# vim:ts=4:sw=4
The global /etc/profile and your own local ~/.bash_profile are read when the shell is invoked as an interactive login shell, for example when you open a remote terminal session to someone else's machine, or when you log into your own machine without X Windows running, or when you hit ctrl-alt-F1 from X Windows to start a virtual terminal session.
The global /etc/bashrc (if it exists) and your own local ~/.bashrc is read when the shell is invoked as an interactive non-login shell, for example when you open up a terminal window in Gnome or KDE.
So it sounds like you'll be wanting it in your /etc/bashrc if you want to set it for all users, or in your ~/.bashrc if it's just for you.
/etc/profile
would be more akin to env variables in windows (as /etc/profile is independent of shell choices)
to set something in /etc/profile you simply do:
VARIABLE_NAME=VALUE_YOU_WA
and then add to the export line the variable name giving you something like:
export PATH USER VARIABLE_NAME
if you don't want to reboot (or log in/out) you can then type:
source /etc/profile
for all practical purposes though, for a one user system ~/.bashrc is the same
In Windows you open up a graphical dialogue, & click the "environment variables" button. In there you can set variables for all users (known in MS Windows as "system variables") or just for the currently logged-in user ("user variables" in Windows)
There's only one right way to do it in MS Windows. It doesn't always work, but at least you know you tried the right thing. :-)
With Linux you gain the freedom to do it different ways, but at the price of reading lots of turgid manuals, and learning the several ways to configure things. It might seem like a pain at first to learn this stuff, yongsing, but it's definitely worth it in the end.
da99rmd,
/etc/bashrc woud apply to all users using the bash shell (which is indeed the default for many linux systems) however if a user is using a different shell /etc/bashrc would be ignored. Take a look at your /etc/passwd file, you will see something like:
guest:x:509:500::/home/gue
indicating the user guest, uses the bash shell. If this here changed (if the user used a different shell such as /bin/csh, or alternatively if they launched their own new shell once logging in anythign entered in /etc/bashrc would not be read by that shell)
/etc/profile on the other hand is read by all user shells regardless of what the user has set
Business Accounts
Answer for Membership
by: da99rmdPosted on 2004-02-24 at 02:24:09ID: 10439635
if you are using bash 3.1_01"
export JAVA_HOME="/usr/java/jdk1.
and if you are using tcsh
setenv JAVA_HOME /usr/java/jdk1.3.1_01
to Add a extra path do this in bash
export PATH=$PATH:/hejsan