TCLUG Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [TCLUG:6937] /etc/profile.d is read when ???



On Mon, 12 Jul 1999, Bob Tanner wrote:

> I am a little confused.
> 
> When does the init scripts inside of /etc/profile.d get read?
> 
> Once, when you a login shell is run?
> 
> Once, when each shell is run?

This depends upon the shell that you are running at login (which is
changed with 'chsh' -- change shell).  To understand the sequence in
which shell files are referenced, read the man pages for the shell
you're interested in. For example, the bash man page reads:

"When bash is invoked as an interactive login shell, it first reads
and executes commands from the file /etc/profile, if that file exists.  
After reading that file, it looks for ~/.bash_profile, ~/.bash_login,
and ~/.profile, in that order, and reads and executes commands from
the first one that exists and is readable.  The --noprofile option may
be used when the shell is started to inhibit this behavior.

"When a login shell exits, bash reads and executes commands from the
file ~/.bash_logout, if it exists."

Assuming that you are using bash as your login shell, you should find
a bit of script similar to the following in your /etc/profile.

    #!/bin/sh
    # /etc/profile -- Global profile for bash/sh

    for i in /etc/profile.d/*.{sh,bash} ; do
        if [ -x ${i} ] ; then
            . ${i}
        fi
    done

Hope this helps.

^chewie

http://nerp.net/~chewie  <<--- Check it out!  I'm selling my truck!