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

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • 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. nft: command not found
  2. CentOS / RHEL : How to add swap file
  3. Rabbitmq install and management
  4. How to change the PATH variable in Linux
  5. Maintaining Linux filesystems using “fsck” and “tune2fs”
  6. CentOS/RHEL7 – Tuned Profiles Oracle
  7. betterdiscordctl Command Examples in Linux
  8. hostname Command Examples in Linux
  9. qemu does not launch : vnc server started
  10. btrfs Command Examples in Linux (cheat sheet)

You May Also Like

Primary Sidebar

Recent Posts

  • powertop Command Examples in Linux
  • powertop: command not found
  • powerstat: command not found
  • powerstat Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright