Motherboard Forums


Reply
Thread Tools Display Modes

Full login sequence documentation ?

 
 
JF Mezei
Guest
Posts: n/a
 
      04-29-2012, 04:47 AM
I am trying to find an authorative list of files which are invoked when
a unix login happens on OS-X. Once you have enterred the username and
password, which files are invoked ?

And when you spawn a new shell, are all those files invoked again or
does the new shell inherit everything (environment variables etc) from
the parent ?)

Are there files common to all shells ? Is is bash, c-shell etc all
dependent on different files being invoked at login ?

Also, a newbie question: are environment variables tied to a shell or to
a process ? For instance, if I am a bash user but invoke a script which
is tshell, will it inherit my environment variables (such as PATH) and
can it then modify them ?
 
Reply With Quote
 
 
 
 
Bob Harris
Guest
Posts: n/a
 
      04-29-2012, 11:50 PM
In article <4f9cc801$0$9708$c3e8da3$(E-Mail Removed) m>,
JF Mezei <(E-Mail Removed)> wrote:

> I am trying to find an authorative list of files which are invoked when
> a unix login happens on OS-X. Once you have enterred the username and
> password, which files are invoked ?
>
> And when you spawn a new shell, are all those files invoked again or
> does the new shell inherit everything (environment variables etc) from
> the parent ?)
>
> Are there files common to all shells ? Is is bash, c-shell etc all
> dependent on different files being invoked at login ?
>
> Also, a newbie question: are environment variables tied to a shell or to
> a process ? For instance, if I am a bash user but invoke a script which
> is tshell, will it inherit my environment variables (such as PATH) and
> can it then modify them ?


Generally, a new shell session starts with the program 'login'
which establishes the user/group and initial environment
variables, then it exec's the user's shell.

The shell's man page will tell you what initialization files are
invoked. The default Mac OS X shell is bash (see man bash).

bash on login invokes /etc/profile. On Mac OS X /etc/profile
invokes /usr/libexec/path_helper which looks for /etc/paths.d and
/etc/manpaths.d directory entries. /etc/profile will then invoke
/etc/bashrc

Next bash will invoke one of the following (first found in the
following order): ~/.bash_profile, ~/.bash_login, or ~/.profile.
Since you create one of these (they do not exist by default), what
these initialization files invoke is totally up to you.

If you create a subshell, then bash will invoke ~/.bashrc, and the
subshell inherits all environment variables and exported shell
functions.

The separation of .bash_proifle from .bashrc allows you to create
a lighter weight .bashrc to speed up subshell creation by
separating environment variable setup and tasks you want to just
once per login from operations that need to be done each time a
sub-shell is created.

One thing some users do, it to "source ~/.bashrc" as part of their
~/.bash_profile.

And some users do now worry about subshell creation performance
(either they do not do it all that often or their system is
sufficiently fast that doing the .bash_profile and .bashrc work
each time is not an issue. These users put everything in .bashrc,
and then have just one command in their .bash_profile "source
~/.bashrc"

You will want to read the man page for your shell. The section
you want in "man bash" is "INVOCATION".
 
Reply With Quote
 
 
 
 
JF Mezei
Guest
Posts: n/a
 
      04-30-2012, 05:30 AM
Bob Harris wrote:

> The shell's man page will tell you what initialization files are
> invoked. The default Mac OS X shell is bash (see man bash).


many many thanks. So if I want to add system wide stuff and aliases, I
should add it to /etc/profile ? Or is that file likely be overwritten by
any software upgrade ?

If a user has a different shell, does this mean that /etc/profile
doesn't necessarily get invoked and there is a totally different chain
of files that are invoked ?
 
Reply With Quote
 
Bruce Esquibel
Guest
Posts: n/a
 
      04-30-2012, 10:41 AM
JF Mezei <(E-Mail Removed)> wrote:

> many many thanks. So if I want to add system wide stuff and aliases, I
> should add it to /etc/profile ? Or is that file likely be overwritten by
> any software upgrade ?


> If a user has a different shell, does this mean that /etc/profile
> doesn't necessarily get invoked and there is a totally different chain
> of files that are invoked ?


I think you would have to read the man pages for each shell offered, I don't
think /etc/profile is considered universal.

What I do think that is common is, the stuff in the user home directory is
the last placed checked.

In many svr4 systems, there used to be /etc/skel which was a directory to
drop in the custom login and profiles for that box/machine. When a user was
created, you usually dropped in copies from there to the home.

Since the users home directory is the last placed checked for customized
settings, it sort of makes more sense to drop in the profile/login/bashrc or
whatever else the desired shell uses there, than to modify the files in
/etc.

Although you can edit the /etc files to your hearts content, it's just one
of those "best practices" kind of thing.

-bruce
(E-Mail Removed)
 
Reply With Quote
 
Paul Sture
Guest
Posts: n/a
 
      04-30-2012, 12:13 PM
On Sun, 29 Apr 2012 19:50:57 -0400, Bob Harris wrote:

> If you create a subshell, then bash will invoke ~/.bashrc, and the
> subshell inherits all environment variables and exported shell
> functions.
>
> The separation of .bash_proifle from .bashrc allows you to create a
> lighter weight .bashrc to speed up subshell creation by separating
> environment variable setup and tasks you want to just once per login
> from operations that need to be done each time a sub-shell is created.
>
> One thing some users do, it to "source ~/.bashrc" as part of their
> ~/.bash_profile.


Thanks Bob. Useful info that I didn't know before.

--
Paul Sture
 
Reply With Quote
 
Barry Margolin
Guest
Posts: n/a
 
      04-30-2012, 01:55 PM
In article <4f9e2363$0$31016$c3e8da3$(E-Mail Removed) om>,
JF Mezei <(E-Mail Removed)> wrote:

> Bob Harris wrote:
>
> > The shell's man page will tell you what initialization files are
> > invoked. The default Mac OS X shell is bash (see man bash).

>
> many many thanks. So if I want to add system wide stuff and aliases, I
> should add it to /etc/profile ? Or is that file likely be overwritten by
> any software upgrade ?
>
> If a user has a different shell, does this mean that /etc/profile
> doesn't necessarily get invoked and there is a totally different chain
> of files that are invoked ?


One thing to remember about all this stuff about shells is that it only
applies to Terminal sessions, not normal Mac GUI logins. The latter
don't involve the Unix shell at all.

--
Barry Margolin, (E-Mail Removed)
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
 
Reply With Quote
 
Bob Harris
Guest
Posts: n/a
 
      05-01-2012, 12:20 AM
In article <4f9e2363$0$31016$c3e8da3$(E-Mail Removed) om>,
JF Mezei <(E-Mail Removed)> wrote:

> Bob Harris wrote:
>
> > The shell's man page will tell you what initialization files are
> > invoked. The default Mac OS X shell is bash (see man bash).

>
> many many thanks. So if I want to add system wide stuff and aliases, I
> should add it to /etc/profile ? Or is that file likely be overwritten by
> any software upgrade ?
>
> If a user has a different shell, does this mean that /etc/profile
> doesn't necessarily get invoked and there is a totally different chain
> of files that are invoked ?


As has been mentioned, you would need to consult each shell's man
page, however, I think the Bourne derived shells (sh, bash, ksh
and zsh) will invoke /etc/profile and csh/tcsh invoke
/etc/csh.login

As to whether it will be replaced by system updates, that is
always a risk, and even if it is not messed with in one update,
nothing says the next update will not play with one of the files.

If you do decide to modify your /etc/profile and/or /etc/csh.login
just make sure you have your own backup copies that you always
keep current with any changes you make.

Perhaps the best idea would be to have your own /etc/profile.local
/etc/csh.login.local and then just add an include to global
initialization script

/etc/profile
. /etc/profile.local

/etc/csh.login
source /etc/csh.login.local

That way you only have to add a single line to any updated
/etc/profile or /etc/csh.login
 
Reply With Quote
 
Bob Harris
Guest
Posts: n/a
 
      05-01-2012, 12:58 AM
In article <4f9e2363$0$31016$c3e8da3$(E-Mail Removed) om>,
JF Mezei <(E-Mail Removed)> wrote:

> Bob Harris wrote:
>
> > The shell's man page will tell you what initialization files are
> > invoked. The default Mac OS X shell is bash (see man bash).

>
> many many thanks. So if I want to add system wide stuff and aliases, I
> should add it to /etc/profile ? Or is that file likely be overwritten by
> any software upgrade ?


NOTE 1: the /etc/profile or /etc/csh.login is ONLY going to be
invoked during the initial session startup. Subshell creation
will not invoke them.

NOTE 2: Not all shells support things like aliases, nor do they
all use the same syntax for everything. Mostly you can export
environment variables, maybe establish personalized stty settings,
runs a very generic script that does some checking or run a
program at session startup. But you need to check any
personalizations at this level with every possible shell that
might use the /etc/profile or /etc/csh.login

If this is really just for your own use, then you might as well
use the home directory shell initialization files. If for the
family, sharing a system, I would still put customizations in
their home directories. If for a department or company wide, then
you have to very careful and test, test, test.

> If a user has a different shell, does this mean that /etc/profile
> doesn't necessarily get invoked and there is a totally different chain
> of files that are invoked ?

 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
I want a full-feature full-size ATX H67 MBO Bill Anderson Asus 3 04-05-2011 02:10 AM
login window empty after initial login window hang ronald.rood@gmail.com Apple 7 02-25-2005 03:09 PM
SP700 Full Documentation JPRW Compaq 0 02-18-2005 11:10 PM
Sound on P4C800ED- any documentation? Michael Hobbs Asus 3 06-14-2004 06:28 AM
Award BIOS upgrade documentation -- where can it be found? Jim in Alaska Asus 1 06-25-2003 05:42 PM


All times are GMT. The time now is 12:30 PM.


Welcome!
Welcome to Motherboard Point
 

Advertisment