# 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