• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • VCS
  • Interview Questions
  • Database
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

Order of environment calls for different OS shells in Linux

by admin

Knowing the order of execution of the environment variables for different OS Shell(s) is very important for a system administrator. This might be useful for setting up cron jobs or for understanding differences in commands run in an interactive shell vs batch jobs using a non-interactive shell.

1. Shell: CSH

Startup (order):

--> .cshrc (always)
--> .login (login shells)

Termination:

--> .logout (login shells)

Others:

.history (saves history based on "$savehist")

2. Shell: tcsh

Startup (order):

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

Termination:

-->.logout (login shells)

Others:

--> .history (saves history based on "$savehist")
--> .cshdirs (saves directory stack)

3. Shell: sh

Startup (order):

--> /etc/profile (login shells)

Termination:

Any command or script specified using the command: trap "command" 0

Others:

--> .profile (login shells)

4. Shell: ksh

Startup (order):

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

Termination:

Any command or script specified using the command: trap "command" 0

5. Shell: bash

Startup (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)

Termination:

--> .bash_logout (login shells)

Others:

--> .inputrc (readline initialization)

6. Shell: zsh

Startup (order):

--> .zshenv (always, unless the -f option is specified)
--> .zprofile (login shells)
--> .zshrc (interactive shells, unless the -f option is specified)
--> .zlogin (login shells)

Termination:

--> .zlogout (login shells)

Filed Under: Linux

Some more articles you might also be interested in …

  1. csvtool: Utility to filter and extract data from CSV formatted sources
  2. btrfs rescue Command Examples in Linux
  3. What is Anacron and usage of Anacron in Linux
  4. esbuild: JavaScript bundler and minifier built for speed
  5. jcal Command Examples
  6. killall Command Examples in Linux
  7. “git am” Command Examples
  8. daemonize: command not found
  9. git config Command Examples
  10. rtorrent: command not found

You May Also Like

Primary Sidebar

Recent Posts

  • Vanilla OS 2 Released: A New Era for Linux Enthusiasts
  • mk Command Examples
  • mixxx Command Examples
  • mix Command Examples

© 2025 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright