Linux novices often get confused over the number of scripts that are executed when a user logs in. Here's the skinny. First you need to understand:

Login Shells vs Interactive Shells

A login shell is started when you log in at a virtual terminal. As far as bash is concerned, it is started with a "-" as its first argument on the command line, or with the "--login" option.

An interactive shell is a shell that is started from the command line after loggin in, or is started from a window manager after login

So, when you sit down at a Linux desktop system and log in via gdm or kdm - the "graphical login managers" - then start a terminal window containing bash, you are running an interactive shell. On the other hand, if you press Ctrl+Alt+F1 to switch to virtual terminal 1 and then log in, you will be starting a login shell. You can see the difference with the ps aux command:

[les@sleipnir les]$ ps aux | grep bash
les       1358  0.0  0.2  7344 2136 pts/1    S    Oct01   0:00 /bin/bash
les      16831  0.0  0.2  7348 2156 pts/2    S    14:49   0:00 -bash
les      16868  0.0  0.2  7356 2160 tty1     S    14:50   0:00 -bash
les      16903  0.0  0.0  3756  564 pts/2    S    14:50   0:00 grep bash
[les@sleipnir les]$

The first line shows an interactive bash shell, running on pts/1 - that was started from within KDE (in fact, pstree will show it as a child of kdeinit). The second line shows a bash shell which was started from an SSH login, running on pts/2. The process name is shown as "-bash", indicating a login shell. The third line shows the login on tty1, which is also a login shell (pstree would show this bash shell as a child of "login".


Page last updated: 03/Oct/2004 Back to Home Copyright © 1987-2010 Les Bell and Associates Pty Ltd. All rights reserved. webmaster@lesbell.com.au

...........................