Jaime Frutos Morales's blog

20/10/2009

BASH 3 startup files

Filed under: Shell scripting, SysAdmin — acidborg @ 17:54

Before explaining the Bourne Again SHell (BASH) 3 default startup files order, here are some needed definitions:

  • Login shell: its first character of argument zero is a or it’s started with the -l option.
  • Interactive shell: it’s started without non-option arguments and without the -c option and its standard input and error are both connected to terminals. It can be started with the -i option.

Now that we know the differences between them, let’s explain the default startup process for each kind of shell in BASH 3:

  • Login shell:
    1. It reads and executes /etc/profile (if it exists)
    2. It reads one (and only one) of the following files and executes it. The order of checking is:
      1. ~/.bash_profile
      2. ~/.bash_login
      3. ~/.profile
  • Interactive shell:
    1. It reads and executes /etc/bash.bashrc (if it exists)
    2. It reads and executes ~/.bashrc (if it exists)

Additionally, login shells reads and executes ~/.bash_logout (if it exists) on exit.

Advertisements

Create a free website or blog at WordPress.com.

%d bloggers like this: