Initialization Files

Different initialization files are used in different linux flavours.

In Linux, what startup and termination files do the various shells use?

csh

Some versions have systemwide .cshrc and .login files. Each version puts them in different places.

Startup

Startup (in following order)

  • .cshrc (always)
  • .login (login shells)

Upon Termination

  • .logout (login shells)

Others

  • .history (saves history based on $savehist)

tcsh

Startup

Startup (in Follwing order)

  • /etc/csh.cshrc (always)
  • /etc/csh.login (login shells)
  • .tcshrc (always)
  • .cshrc (if no .tcshrc file is present)
  • .login (login shells)

Upon Termination

  • .logout (login shells)

Others

  • .history (saves history based on $savehist)
  • .cshdirs (saves directory stack)

sh

Startup

Startup (in Follwing order)

  • /etc/profile (login shells)
  • .profile (login shells)

Upon Termination

  • Any command or script specified using the command,
trap {command} 0 

ksh

Startup

Startup (in Follwing order)

  • /etc/profile (login shells)
  • .profile (login shells)
  • $ENV (always, if it is set)

Upon Termination

  • Any command or script specified using the command,
trap {command} 0 

bash

Startup

Startup (in Follwing order)

  • /etc/profile (login shells)
  • .bash_profile (login shells)
  • .profile (login if no .bash_profile file is present)
  • .bashrc (interactive non-login shells)
  • $ENV (non-interactive shells)

Upon Termination

  • .bash_logout (login shells)

Others

  • .inputrc (readline initialization)

Subscribe For More Content