Kevin Warrington

Loading clever subtitle...

Shell Modes and Init Files


There are two main shell modes:

1. Login

When a user logs in with a non-graphical interface or SSH.

2. Interactive

When a user has a prompt and standard in/out are connected to the terminal.

Combinations of Modes

A shell can be initialized with the following mode combinations:

Login + Interactive

You will be forwarded to the users home directory, with the users environment.

  • log in to a remote system via SSH
  • new terminal tab, Mac OS X
  • sudo su -

files sourced:

# The systemwide initialization file

# The personal initialization files, first one found, in order

Non-login + Interactive

You will stay in the current directory, but will have the users environment.

  • new terminal tab, linux
  • start new shell process ($ bash)
  • execute script remotely and request terminal (ssh user@host -t ‘echo $PWD’)
  • sudo su

files sourced:

# The individual per-interactive-shell startup file

Non-login + Non-Interactive

You will stay in the current directory and keep your current environment.

  • run an executable with #!/usr/bin/env bash shebang
  • run a script ($ bash
  • execute script remotely (ssh user@host ‘echo $PWD’)

files sourced:

source $BASH_ENV