OnWorks Linux and Windows Online WorkStations

Logo

Free Hosting Online for WorkStations

< Previous | Contents | Next >

How Is The Environment Established?

When we log on to the system, the bash program starts, and reads a series of configura- tion scripts called startup files, which define the default environment shared by all users. This is followed by more startup files in our home directory that define our personal envi- ronment. The exact sequence depends on the type of shell session being started. There are two kinds: a login shell session and a non-login shell session.

A login shell session is one in which we are prompted for our username and password; when we start a virtual console session, for example. A non-login shell session typically occurs when we launch a terminal session in the GUI.

Login shells read one or more startup files as shown in Table 11-2:


Table 11-2: Startup Files For Login Shell Sessions


File Contents

File Contents

/etc/profile A global configuration script that applies to all users.


image

~/.bash_profile A user's personal startup file. Can be used to extend or

override settings in the global configuration script.


image

~/.bash_login If ~/.bash_profile is not found, bash attempts to

read this script.


image

~/.profile If neither ~/.bash_profile nor ~/.bash_login

is found, bash attempts to read this file. This is the default in Debian-based distributions, such as Ubuntu.


image


Non-login shell sessions read the following startup files:


Table 11-3: Startup Files For Non-Login Shell Sessions


File Contents

File Contents

/etc/bash.bashrc A global configuration script that applies to all users.


image

~/.bashrc A user's personal startup file. Can be used to extend or

override settings in the global configuration script.


image


In addition to reading the startup files above, non-login shells also inherit the environ- ment from their parent process, usually a login shell.

Take a look and see which of these startup files are installed. Remembersince most of the filenames listed above start with a period (meaning that they are hidden), we will need to use the “-a” option when using ls.

The ~/.bashrc file is probably the most important startup file from the ordinary user’s point of view, since it is almost always read. Non-login shells read it by default and most startup files for login shells are written in such a way as to read the ~/.bashrc file as well.


 

Top OS Cloud Computing at OnWorks: