"An interactive login shell is started
after a successful login, using
/bin/login, by reading the /etc/passwd
file. This shell invocation normally
reads /etc/profile and its private
equivalent ~/.bash_profile upon
An interactive non-login shell is
normally started at the command-line
using a shell program (e.g.,
[prompt]$/bin/bash) or by the /bin/su
command. An interactive non-login
shell is also started with a terminal
program such as xterm or konsole from
within a graphical environment. This
type of shell invocation normally
copies the parent environment and then
reads the user's ~/.bashrc file for
additional startup configuration
Therefore I would not put environment variables in bashrc, because it is not only against common convention, but you will also miss your bashrc varialbles when invoking a terminal from a graphical Desktop environment.
On Redhat in the
/etc/profile I found this comment:
"System wide aliases and functions should go in /etc/bashrc. Personal
environment variables and startup programs should go into
~/.bash_profile. Personal aliases and functions should go into
So if you want to set environment variables on a user basis, do it in the user's .bash_profile file.
Heading over to the
.bash_profile I read:
"Personal environment variables and startup programs.
Personal aliases and functions should go in ~/.bashrc. System wide
environment variables and startup programs are in /etc/profile.
System wide aliases and functions are in /etc/bashrc."
If you want only root to see programs residing, for instance in /
sbin I would add that path to root's
.bash_profile file. But if you want every user to see what root specific programs are installed on your box I would put
/etc/.profile. Now every user can use tab completion to look for root specific programs and elevate rights if necessary.
Special Case: SSH
When ssh is started with a commandline, an interactive login shell is started. But in this case
/etc/profile is not read. When I defined environment variables in the
.bash_profile file of each user it worked with ssh.