Skip to main content
The 2024 Developer Survey results are live! See the results
added 6189 characters in body
Source Link
Elliptical view
  • 1.2k
  • 2
  • 15
  • 25
# For BASH: Read down the appropriate column.!/bin/bash Executes A, then B, then C,# /etc./profile
# The B1, B2, B3 means it executes only the first#version=1 of those files found.  (A)
# or (B2) means it is normally sourced by (readIn byvi/vim andsay included in):set thets=4


# primary file, in this case AFOR orALL B2.LOGINS:
#
# +---------------------------------+-------+-----+------------+
# |                                 | Interactive | non-Inter. |
# +---------------------------------+-------+-----+------------+
# |                                 | login |    non-login     |
# +---------------------------------+-------+-----+------------+
# |                                 |       |     |            |
# |   ALL USERS:                    |       |     |            |
# +---------------------------------+-------+-----+------------+
# |BASH_ENV                         |       |     |     A      | not interactive nor login
# |                                 |       |     |      FIRST RUN     |
# +---------------------------------+-------+-----+------------+
# |/etc/profile                     |   A   |     |            | set PATH & PS1, & call following:
# +---------------------------------+-------+-----+------------+
# |/etc/bash.bashrc                 |  (ATHIS)  |  A  |            | BetterFOR PS1SYSTEM +LOGIN, command-not-found 
# +---------------------------------+-------+-----+------------+
# |/etc/profilee.d/bash_completiong.sh|  (A)  |     |      PS1 and PATH ??.   |
#It +---------------------------------+-------+-----+------------+runs:
# |/etc/profile.d/vte-2.91.sh       |  (A)  |     |            | Virt. Terminal Emulator
# |/etc/profile.d/vtebash.sh            |  (A)  |     |            |
# +---------------------------------+-------+-----+------------+
# |                        bashrc        FOR |SYSTEM STARTUP      |     |            |
# |  profile Amight SPECIFICalso USERrun:              |       |     |            |
# +---------------------------------+-------+-----+------------+
# |~/.bash_profile    (bash only)   |   B1  |     |            | (doesn't currently exist) 
# +---------------------------------+-------+-----+------------+
# |~/.bash_login      (bash only)   |   B2  |     |            | (didn't exist) **
# +---------------------------------+-------+-----+------------+
# |~etc/.profile         (all shells)  |   B3  |     |            | (doesn't currently exist)
# +---------------------------------+-------+-----+------------+
# |~/.bashrc          (bash only)   |  (B2) |  B  |            | colorizes bash: su=red, other_users=green
# +---------------------------------+-------+-----+------------+
# |                                 |       |     |            |
# +---------------------------------+-------+-----+------------+
# |~d/*.bash_logout                   |    C  |     |      sh     FOR |
#SYSTEM +---------------------------------+-------+-----+------------+STARTUP
#
#   THEN  RUN    ~/.bash_profile            FOR USER   LOGIN.   e.g. colors.            It runs: 
#                          ~/.bashrc        FOR USER   STARTUP.                         it runs:
#                   /etc/bash.shared        FOR USER   STARTUP


# ELSE:
#
#   FIRST RUN       /etc/bash.bashrc        FOR SYSTEM STARTUP
#
#   THEN RUN               ~/.bashrc        FOR USER   STARTUP                          It runs:
#                   /etc/bash.shared        FOR USER   STARTUP



# From http://tristram.squarespace.com/home/2012/7/20/why-profile-bash_profile-and-bash_login.html
#
#   "bash allows two alternatives for .bash_profile  (to get bash user specifics when logging in):
#       ~/.bash_login   , derived from the C shell's             file  named .login,    and 
#       ~/.profile      , derived from the Bourne and Korn shell files named .profile. 
#
#     Only one of these three is read when you log in.  Read first one found in this order:
#       ~/.bash_profile     i.e. if this is found read it, or       <-- I have this: hwj
#       ~/.bash_login            if this is found read it, or
#       ~/.profile               if this is found read it, else fail.
#
#   One advantage of bash's ability to look for either synonym is that 
#       if you have been using sh (the Bourne shell) you can retain your .profile .
#
#       If you need to add bash-specific commands, you can put them in .bash_profile 
#           followed by the command source .profile. 
#
#   When you log in, all the bash-specific commands will be executed and 
#       then bash will source .profile, executing the remaining shared bash AND Bourne commands. 
#
#       If you decide to switch to using sh (the Bourne shell) you don't have 
#           to modify your existing files.
#
#
#   A similar approach was intended for .bash_login and the C shell .login, 
#       but due to differences in the basic syntax of the shells, this is not a good idea."



# For BASH:  Read down the appropriate column.  
#   Executes A, then B, then C.
#     Executes only the first found of B1, B2, B3.
#       For bash  A then sources (A)  and  B2 then sources (B2).
#
#
# +----------------------------------+-------+-----+------------+
# |                                  | Interactive | non-Inter. |
# |                                  |    shell    |  script    |
# +----------------------------------+-------+-----+------------+
# |                                  | login |    non-login     |
# +==================================+=======+=====+============+
# |                                  |       |     |            |
# | Runs first                       |       |     |            |
# |        ALL USERS (system)        |       |     |            |
# |                                  |       |     |            |
# +==================================+=======+=====+============+
# |/etc/profile       (all shells)   |   A   |     |            | (this file) set PS1, & then source the following:
# +----------------------------------+-------+-----+------------+
# | /etc/bash.bashrc   (bash only)   |  (A)  |  A  |            |          Better PS1 + command-not-found
# +----------------------------------+-------+-----+------------+
# | /etc/profile.d/bash_completion.sh|  (A)  |     |            |
# +----------------------------------+-------+-----+------------+
# | /etc/profile.d/vte-2.91.sh       |  (A)  |     |            | Virt. Terminal Emulator
# | /etc/profile.d/vte.sh            |  (A)  |     |            | 
# +----------------------------------+-------+-----+------------+
# |                                  |       |     |            |
# |BASH_ENV                          |       |     |     A      | not interactive script (only reads the environment)
# +==================================+=======+=====+============+
#
# +==================================+=======+=====+============+
# |                                  |       |     |            |
# | Runs second                      |       |     |            |
# |   SPECIFIC USER (root & howard)  |       |     |            |
# |                                  |       |     |            |
# +==================================+=======+=====+============+
# |~/.bash_profile    (bash only)    |   B1  |     |            | renamed /root/.profile and /home/howard/.bash_login to this
# +----------------------------------+-------+-----+------------+
# |~/.bash_login      (bash & csh)   |   B2  |     |            | (didn't exist) **
# +----------------------------------+-------+-----+------------+
# | ~/.bashrc          (bash only)   |  (B2) |  B  |            | 1) extends bash PS1 prompt to colorize: su=red, other_users=green
# |  . ~/bash.shared                 |       |     |            | 2) sources ~/bash.shared to load shared stuff
# +----------------------------------+-------+-----+------------+
# |~/.profile         (all shells)   |   B3  |     |            | (didn't exist - now a link to .bash_profile)  ????
# +----------------------------------+-------+-----+------------+
#
# +----------------------------------+-------+-----+------------+
# |~/.bash_logout                    |    C  |     |            | gets sourced when we log off
# +----------------------------------+-------+-----+------------+
#
# ** (sources !/.bashrc to colorize login, for when booting into non-gui)

And this note atfor what it's worth here is the head of eachrest of the other setup files to refer to it:my /etc/profile script

    # TIP:=== SEEGet TABLEdebugging functions ==========================================================
    caller="/etc/profile"
    . /etc/bash.say.shared      # debugging primitives for bash_say function used below and $LS_COLORS var
    n=$(( n + 2 ))  #  indent
    
    # === Source stuff to setup a monitor ==================================================
    if [[ $- == *i* ]]; then        # 'himBHs', where i means interactive
        bash_say 'Interactive login.  Setting up monitor.'
        . /etc/bash.bashrc          # Set PATH, umask.  
                                    # If interactive also setup dircolors, shell options, chroot prompt, command-completion
    fi
    
    
    # === Source any profile extensions ====================================================
    bash_say ""
    bash_say "Sourcing any extensions..."
    n=$(( n + 2 ))  #  indent
    
        if [ -d /etc/profile.d ]; then
    
          for src_d in /etc/profile.d/*.sh; ofdo
            if [ -r $src_d ]; then
              bash_say "Sourcing  $src_d"
              . $src_d
            fi
          done
          unset src_d
        fi
    n=$(( n - 2 ))  #  indent
    #bash_say "---Done sourcing extensions"
    
    
    #unset bash_say
    n=$(( n - 2 ))  # outdent
    bash_say ""

And also here is my included file /etc/bash.say.shared with indenting functions used to help me debug what exactly was going on:

# /etc/bash.say.shared

# # === BASH SETUPSTARTUP FILESUTILITIES ==============================================================================
# Sourced by both:  /etc/profile (login entry point)   and  /etc/bash.bashrc (terminal setup entry point)
#   $caller is the caller


# --- Utility functions to show indented status lines ------------------------------------------------
#if test "${BASH_SAY+word}"; then       # Don't reload if already defined before
#   was="already was ";
#else

    # --- ENABLED? --------------------------------------------------------------------
    # Set to 'true' to show debugging 'bash_say' messages when starting up bash
    export BASH_SAY=true
    export BASH_SAY=false


    # --- FUNCTIONS -------------------------------------------------------------------
    # Create spaces function, if not already defined
    spaces() { local count=$1; while (( count-- )) ; do echo -n " "; done;}     # Print n spaces

    bash_say() {
        # Only echo if enabled AND THEIRwhen LOADthere SEQUENCEis a tty.  Don't echo status for SSH because it messes up remote scp command.
        if [ $BASH_SAY = 'true'  -a  -t 0 ]; then spaces $n; echo -e "$1 "; fi  #Comment in to debug    #can't get $0 to work
        : ;     #Dummy function filler for when above line is commented out
    }
    bash_say test

    bash_sourcing() { bash_say ""; bash_say "Sourcing $1"; }    # Use at top of files

    # Needed so others can use them
    export -f spaces
    export -f bash_say
    export -f bash_sourcing
#fi

bash_sourcing "$caller";
n=$(( n + 2 ))      #  indent
    bash_sourcing "/etc/bash.say.shared";
    n=$(( n + 2 ))  #  indent
        bash_say "Bash startup debugging:  ${was}enabled";
        unset was
n=$(( n - 4 ))      # outdent x2
bash_say "";        # line break
# For BASH: Read down the appropriate column. Executes A, then B, then C, etc.
# The B1, B2, B3 means it executes only the first of those files found.  (A)
# or (B2) means it is normally sourced by (read by and included in) the
# primary file, in this case A or B2.
#
# +---------------------------------+-------+-----+------------+
# |                                 | Interactive | non-Inter. |
# +---------------------------------+-------+-----+------------+
# |                                 | login |    non-login     |
# +---------------------------------+-------+-----+------------+
# |                                 |       |     |            |
# |   ALL USERS:                    |       |     |            |
# +---------------------------------+-------+-----+------------+
# |BASH_ENV                         |       |     |     A      | not interactive nor login
# |                                 |       |     |            |
# +---------------------------------+-------+-----+------------+
# |/etc/profile                     |   A   |     |            | set PATH & PS1, & call following:
# +---------------------------------+-------+-----+------------+
# |/etc/bash.bashrc                 |  (A)  |  A  |            | Better PS1 + command-not-found 
# +---------------------------------+-------+-----+------------+
# |/etc/profile.d/bash_completion.sh|  (A)  |     |            |
# +---------------------------------+-------+-----+------------+
# |/etc/profile.d/vte-2.91.sh       |  (A)  |     |            | Virt. Terminal Emulator
# |/etc/profile.d/vte.sh            |  (A)  |     |            |
# +---------------------------------+-------+-----+------------+
# |                                 |       |     |            |
# |   A SPECIFIC USER:              |       |     |            |
# +---------------------------------+-------+-----+------------+
# |~/.bash_profile    (bash only)   |   B1  |     |            | (doesn't currently exist) 
# +---------------------------------+-------+-----+------------+
# |~/.bash_login      (bash only)   |   B2  |     |            | (didn't exist) **
# +---------------------------------+-------+-----+------------+
# |~/.profile         (all shells)  |   B3  |     |            | (doesn't currently exist)
# +---------------------------------+-------+-----+------------+
# |~/.bashrc          (bash only)   |  (B2) |  B  |            | colorizes bash: su=red, other_users=green
# +---------------------------------+-------+-----+------------+
# |                                 |       |     |            |
# +---------------------------------+-------+-----+------------+
# |~/.bash_logout                   |    C  |     |            |
# +---------------------------------+-------+-----+------------+
#
# ** (sources !/.bashrc to colorize login, for when booting into non-gui)

And this note at the head of each of the other setup files to refer to it:

# TIP: SEE TABLE in /etc/profile of BASH SETUP FILES AND THEIR LOAD SEQUENCE
#!/bin/bash     # /etc/profile
#version=1      # In vi/vim say  :set ts=4


# FOR ALL LOGINS:
#
#   FIRST RUN       /etc/profile (THIS)     FOR SYSTEM LOGIN,   e.g. PS1 and PATH ??.   It runs:
#                   /etc/bash.bashrc        FOR SYSTEM STARTUP                          profile might also run:
#                   /etc/profile.d/*.sh     FOR SYSTEM STARTUP
#
#   THEN  RUN    ~/.bash_profile            FOR USER   LOGIN.   e.g. colors.            It runs: 
#                          ~/.bashrc        FOR USER   STARTUP.                         it runs:
#                   /etc/bash.shared        FOR USER   STARTUP


# ELSE:
#
#   FIRST RUN       /etc/bash.bashrc        FOR SYSTEM STARTUP
#
#   THEN RUN               ~/.bashrc        FOR USER   STARTUP                          It runs:
#                   /etc/bash.shared        FOR USER   STARTUP



# From http://tristram.squarespace.com/home/2012/7/20/why-profile-bash_profile-and-bash_login.html
#
#   "bash allows two alternatives for .bash_profile  (to get bash user specifics when logging in):
#       ~/.bash_login   , derived from the C shell's             file  named .login,    and 
#       ~/.profile      , derived from the Bourne and Korn shell files named .profile. 
#
#     Only one of these three is read when you log in.  Read first one found in this order:
#       ~/.bash_profile     i.e. if this is found read it, or       <-- I have this: hwj
#       ~/.bash_login            if this is found read it, or
#       ~/.profile               if this is found read it, else fail.
#
#   One advantage of bash's ability to look for either synonym is that 
#       if you have been using sh (the Bourne shell) you can retain your .profile .
#
#       If you need to add bash-specific commands, you can put them in .bash_profile 
#           followed by the command source .profile. 
#
#   When you log in, all the bash-specific commands will be executed and 
#       then bash will source .profile, executing the remaining shared bash AND Bourne commands. 
#
#       If you decide to switch to using sh (the Bourne shell) you don't have 
#           to modify your existing files.
#
#
#   A similar approach was intended for .bash_login and the C shell .login, 
#       but due to differences in the basic syntax of the shells, this is not a good idea."



# For BASH:  Read down the appropriate column.  
#   Executes A, then B, then C.
#     Executes only the first found of B1, B2, B3.
#       For bash  A then sources (A)  and  B2 then sources (B2).
#
#
# +----------------------------------+-------+-----+------------+
# |                                  | Interactive | non-Inter. |
# |                                  |    shell    |  script    |
# +----------------------------------+-------+-----+------------+
# |                                  | login |    non-login     |
# +==================================+=======+=====+============+
# |                                  |       |     |            |
# | Runs first                       |       |     |            |
# |        ALL USERS (system)        |       |     |            |
# |                                  |       |     |            |
# +==================================+=======+=====+============+
# |/etc/profile       (all shells)   |   A   |     |            | (this file) set PS1, & then source the following:
# +----------------------------------+-------+-----+------------+
# | /etc/bash.bashrc   (bash only)   |  (A)  |  A  |            |          Better PS1 + command-not-found
# +----------------------------------+-------+-----+------------+
# | /etc/profile.d/bash_completion.sh|  (A)  |     |            |
# +----------------------------------+-------+-----+------------+
# | /etc/profile.d/vte-2.91.sh       |  (A)  |     |            | Virt. Terminal Emulator
# | /etc/profile.d/vte.sh            |  (A)  |     |            | 
# +----------------------------------+-------+-----+------------+
# |                                  |       |     |            |
# |BASH_ENV                          |       |     |     A      | not interactive script (only reads the environment)
# +==================================+=======+=====+============+
#
# +==================================+=======+=====+============+
# |                                  |       |     |            |
# | Runs second                      |       |     |            |
# |   SPECIFIC USER (root & howard)  |       |     |            |
# |                                  |       |     |            |
# +==================================+=======+=====+============+
# |~/.bash_profile    (bash only)    |   B1  |     |            | renamed /root/.profile and /home/howard/.bash_login to this
# +----------------------------------+-------+-----+------------+
# |~/.bash_login      (bash & csh)   |   B2  |     |            | (didn't exist) **
# +----------------------------------+-------+-----+------------+
# | ~/.bashrc          (bash only)   |  (B2) |  B  |            | 1) extends bash PS1 prompt to colorize: su=red, other_users=green
# |  . ~/bash.shared                 |       |     |            | 2) sources ~/bash.shared to load shared stuff
# +----------------------------------+-------+-----+------------+
# |~/.profile         (all shells)   |   B3  |     |            | (didn't exist - now a link to .bash_profile)  ????
# +----------------------------------+-------+-----+------------+
#
# +----------------------------------+-------+-----+------------+
# |~/.bash_logout                    |    C  |     |            | gets sourced when we log off
# +----------------------------------+-------+-----+------------+
#
# ** (sources !/.bashrc to colorize login, for when booting into non-

And for what it's worth here is the rest of my /etc/profile script

    # === Get debugging functions ==========================================================
    caller="/etc/profile"
    . /etc/bash.say.shared      # debugging primitives for bash_say function used below and $LS_COLORS var
    n=$(( n + 2 ))  #  indent
    
    # === Source stuff to setup a monitor ==================================================
    if [[ $- == *i* ]]; then        # 'himBHs', where i means interactive
        bash_say 'Interactive login.  Setting up monitor.'
        . /etc/bash.bashrc          # Set PATH, umask.  
                                    # If interactive also setup dircolors, shell options, chroot prompt, command-completion
    fi
    
    
    # === Source any profile extensions ====================================================
    bash_say ""
    bash_say "Sourcing any extensions..."
    n=$(( n + 2 ))  #  indent
    
        if [ -d /etc/profile.d ]; then
    
          for src_d in /etc/profile.d/*.sh; do
            if [ -r $src_d ]; then
              bash_say "Sourcing  $src_d"
              . $src_d
            fi
          done
          unset src_d
        fi
    n=$(( n - 2 ))  #  indent
    #bash_say "---Done sourcing extensions"
    
    
    #unset bash_say
    n=$(( n - 2 ))  # outdent
    bash_say ""

And also here is my included file /etc/bash.say.shared with indenting functions used to help me debug what exactly was going on:

# /etc/bash.say.shared

# # === BASH STARTUP UTILITIES ==============================================================================
# Sourced by both:  /etc/profile (login entry point)   and  /etc/bash.bashrc (terminal setup entry point)
#   $caller is the caller


# --- Utility functions to show indented status lines ------------------------------------------------
#if test "${BASH_SAY+word}"; then       # Don't reload if already defined before
#   was="already was ";
#else

    # --- ENABLED? --------------------------------------------------------------------
    # Set to 'true' to show debugging 'bash_say' messages when starting up bash
    export BASH_SAY=true
    export BASH_SAY=false


    # --- FUNCTIONS -------------------------------------------------------------------
    # Create spaces function, if not already defined
    spaces() { local count=$1; while (( count-- )) ; do echo -n " "; done;}     # Print n spaces

    bash_say() {
        # Only echo if enabled AND when there is a tty.  Don't echo status for SSH because it messes up remote scp command.
        if [ $BASH_SAY = 'true'  -a  -t 0 ]; then spaces $n; echo -e "$1 "; fi  #Comment in to debug    #can't get $0 to work
        : ;     #Dummy function filler for when above line is commented out
    }
    bash_say test

    bash_sourcing() { bash_say ""; bash_say "Sourcing $1"; }    # Use at top of files

    # Needed so others can use them
    export -f spaces
    export -f bash_say
    export -f bash_sourcing
#fi

bash_sourcing "$caller";
n=$(( n + 2 ))      #  indent
    bash_sourcing "/etc/bash.say.shared";
    n=$(( n + 2 ))  #  indent
        bash_say "Bash startup debugging:  ${was}enabled";
        unset was
n=$(( n - 4 ))      # outdent x2
bash_say "";        # line break
added 1 character in body
Source Link
Elliptical view
  • 1.2k
  • 2
  • 15
  • 25
# For BASH: Read down the appropriate column. Executes A, then B, then C, etc.
# The B1, B2, B3 means it executes only the first of those files found.  (A)
# or (B2) means it is normally sourced by (read by and included in) the
# primary file, in this case A or B2.
#
# +---------------------------------+-------+-----+------------+
# |                                 | Interactive | non-Inter. |
# +---------------------------------+-------+-----+------------+
# |                                 | login |    non-login     |
# +---------------------------------+-------+-----+------------+
# |                                 |       |     |            |
# |   ALL USERS:                    |       |     |            |
# +---------------------------------+-------+-----+------------+
# |BASH_ENV                         |       |     |     A      | not interactive ornor login
# |                                 |       |     |            |
# +---------------------------------+-------+-----+------------+
# |/etc/profile                     |   A   |     |            | set PATH & PS1, & call following:
# +---------------------------------+-------+-----+------------+
# |/etc/bash.bashrc                 |  (A)  |  A  |            | Better PS1 + command-not-found 
# +---------------------------------+-------+-----+------------+
# |/etc/profile.d/bash_completion.sh|  (A)  |     |            |
# +---------------------------------+-------+-----+------------+
# |/etc/profile.d/vte-2.91.sh       |  (A)  |     |            | Virt. Terminal Emulator
# |/etc/profile.d/vte.sh            |  (A)  |     |            |
# +---------------------------------+-------+-----+------------+
# |                                 |       |     |            |
# |   A SPECIFIC USER:              |       |     |            |
# +---------------------------------+-------+-----+------------+
# |~/.bash_profile    (bash only)   |   B1  |     |            | (doesn't currently exist) 
# +---------------------------------+-------+-----+------------+
# |~/.bash_login      (bash only)   |   B2  |     |            | (didn't exist) **
# +---------------------------------+-------+-----+------------+
# |~/.profile         (all shells)  |   B3  |     |            | (doesn't currently exist)
# +---------------------------------+-------+-----+------------+
# |~/.bashrc          (bash only)   |  (B2) |  B  |            | colorizes bash: su=red, other_users=green
# +---------------------------------+-------+-----+------------+
# |                                 |       |     |            |
# +---------------------------------+-------+-----+------------+
# |~/.bash_logout                   |    C  |     |            |
# +---------------------------------+-------+-----+------------+
#
# ** (sources !/.bashrc to colorize login, for when booting into non-gui)
# For BASH: Read down the appropriate column. Executes A, then B, then C, etc.
# The B1, B2, B3 means it executes only the first of those files found.  (A)
# or (B2) means it is normally sourced by (read by and included in) the
# primary file, in this case A or B2.
#
# +---------------------------------+-------+-----+------------+
# |                                 | Interactive | non-Inter. |
# +---------------------------------+-------+-----+------------+
# |                                 | login |    non-login     |
# +---------------------------------+-------+-----+------------+
# |                                 |       |     |            |
# |   ALL USERS:                    |       |     |            |
# +---------------------------------+-------+-----+------------+
# |BASH_ENV                         |       |     |     A      | not interactive or login
# |                                 |       |     |            |
# +---------------------------------+-------+-----+------------+
# |/etc/profile                     |   A   |     |            | set PATH & PS1, & call following:
# +---------------------------------+-------+-----+------------+
# |/etc/bash.bashrc                 |  (A)  |  A  |            | Better PS1 + command-not-found 
# +---------------------------------+-------+-----+------------+
# |/etc/profile.d/bash_completion.sh|  (A)  |     |            |
# +---------------------------------+-------+-----+------------+
# |/etc/profile.d/vte-2.91.sh       |  (A)  |     |            | Virt. Terminal Emulator
# |/etc/profile.d/vte.sh            |  (A)  |     |            |
# +---------------------------------+-------+-----+------------+
# |                                 |       |     |            |
# |   A SPECIFIC USER:              |       |     |            |
# +---------------------------------+-------+-----+------------+
# |~/.bash_profile    (bash only)   |   B1  |     |            | (doesn't currently exist) 
# +---------------------------------+-------+-----+------------+
# |~/.bash_login      (bash only)   |   B2  |     |            | (didn't exist) **
# +---------------------------------+-------+-----+------------+
# |~/.profile         (all shells)  |   B3  |     |            | (doesn't currently exist)
# +---------------------------------+-------+-----+------------+
# |~/.bashrc          (bash only)   |  (B2) |  B  |            | colorizes bash: su=red, other_users=green
# +---------------------------------+-------+-----+------------+
# |                                 |       |     |            |
# +---------------------------------+-------+-----+------------+
# |~/.bash_logout                   |    C  |     |            |
# +---------------------------------+-------+-----+------------+
#
# ** (sources !/.bashrc to colorize login, for when booting into non-gui)
# For BASH: Read down the appropriate column. Executes A, then B, then C, etc.
# The B1, B2, B3 means it executes only the first of those files found.  (A)
# or (B2) means it is normally sourced by (read by and included in) the
# primary file, in this case A or B2.
#
# +---------------------------------+-------+-----+------------+
# |                                 | Interactive | non-Inter. |
# +---------------------------------+-------+-----+------------+
# |                                 | login |    non-login     |
# +---------------------------------+-------+-----+------------+
# |                                 |       |     |            |
# |   ALL USERS:                    |       |     |            |
# +---------------------------------+-------+-----+------------+
# |BASH_ENV                         |       |     |     A      | not interactive nor login
# |                                 |       |     |            |
# +---------------------------------+-------+-----+------------+
# |/etc/profile                     |   A   |     |            | set PATH & PS1, & call following:
# +---------------------------------+-------+-----+------------+
# |/etc/bash.bashrc                 |  (A)  |  A  |            | Better PS1 + command-not-found 
# +---------------------------------+-------+-----+------------+
# |/etc/profile.d/bash_completion.sh|  (A)  |     |            |
# +---------------------------------+-------+-----+------------+
# |/etc/profile.d/vte-2.91.sh       |  (A)  |     |            | Virt. Terminal Emulator
# |/etc/profile.d/vte.sh            |  (A)  |     |            |
# +---------------------------------+-------+-----+------------+
# |                                 |       |     |            |
# |   A SPECIFIC USER:              |       |     |            |
# +---------------------------------+-------+-----+------------+
# |~/.bash_profile    (bash only)   |   B1  |     |            | (doesn't currently exist) 
# +---------------------------------+-------+-----+------------+
# |~/.bash_login      (bash only)   |   B2  |     |            | (didn't exist) **
# +---------------------------------+-------+-----+------------+
# |~/.profile         (all shells)  |   B3  |     |            | (doesn't currently exist)
# +---------------------------------+-------+-----+------------+
# |~/.bashrc          (bash only)   |  (B2) |  B  |            | colorizes bash: su=red, other_users=green
# +---------------------------------+-------+-----+------------+
# |                                 |       |     |            |
# +---------------------------------+-------+-----+------------+
# |~/.bash_logout                   |    C  |     |            |
# +---------------------------------+-------+-----+------------+
#
# ** (sources !/.bashrc to colorize login, for when booting into non-gui)
added 14 characters in body
Source Link
Elliptical view
  • 1.2k
  • 2
  • 15
  • 25

Building on Flimm's great answer above, I inseredinserted this new comment at the head of my Debian /etc/profile/etc/profile, (you might need to adjust it for your distro.):

Worth noting I think is that Debian's /etc/profile/etc/profile by default sources (includes) /etc/bash.bashrc/etc/bash.bashrc, (that's when /etc/bash.bashrc/etc/bash.bashrc exists). So login scripts read both /etc/etc files, while non-login reads only bash.bashrc.

Also of note is that /etc/bash.bashrc/etc/bash.bashrc is set to do nothing when it's not run interactively. So these two files are only for interactive scripts.

Building on Flimm's great answer above, I insered this new comment at the head of my Debian /etc/profile, (you might need to adjust it for your distro.):

Worth noting I think is that Debian's /etc/profile by default sources (includes) /etc/bash.bashrc (that's when /etc/bash.bashrc exists). So login scripts read both /etc files, while non-login reads only bash.bashrc.

Also of note is that /etc/bash.bashrc is set to do nothing when it's not run interactively. So these two files are only for interactive scripts.

Building on Flimm's great answer above, I inserted this new comment at the head of my Debian /etc/profile, (you might need to adjust it for your distro.):

Worth noting I think is that Debian's /etc/profile by default sources (includes) /etc/bash.bashrc, (that's when /etc/bash.bashrc exists). So login scripts read both /etc files, while non-login reads only bash.bashrc.

Also of note is that /etc/bash.bashrc is set to do nothing when it's not run interactively. So these two files are only for interactive scripts.

Source Link
Elliptical view
  • 1.2k
  • 2
  • 15
  • 25
Loading