Page tree
Skip to end of metadata
Go to start of metadata

Problem

Shell startup file .bashrc not being sourced specially on Topaz

This is specially a Centos / RedHat Specific issue as the .bashrc is sourced by the user shell startup

  • Magnus / Galaxy / Zeus are essentially based on SuSE SLES12 where the default user profile automatically sources this
  • Whereas Topaz ie Centos 7 does not


To understand the problem 

Centos Specific basically in short

  • ".bash_profile" is sourced for login shell
  • ".bashrc" is sourced for interactive non-login shells.

The dummy default Centos Specific home area, they have a dummy file for .bash_profile and .bashrc ie

  • Notice in the dummy default .bashprofile they execute ~/.bashrc
  • Notice in the dummy default .bashrc they source /etc/bashrc
  • So they have to be explicitly sourced in the user version's of .bashprofile and .bashrc which is not needed in SUSE SLES12
root@topaz-1:/etc/skel>pwd
/etc/skel

root@topaz-1:/etc/skel>cat /etc/redhat-release 
CentOS Linux release 7.6.1810 (Core) 

root@topaz-1:/etc/skel>ls -al
total 36
drwxr-xr-x.   2 root root  4096 Sep 26 14:50 .
drwxr-xr-x. 113 root root 12288 Jan  3 13:24 ..
-rw-r--r--.   1 root root    18 Oct 31  2018 .bash_logout
-rw-r--r--.   1 root root   193 Oct 31  2018 .bash_profile
-rw-r--r--.   1 root root   231 Oct 31  2018 .bashrc
-rw-r--r--    1 root root   334 Oct 30  2018 .emacs
-rw-r--r--    1 root root   658 Oct 31  2018 .zshrc

root@topaz-1:/etc/skel>cat .bashrc 
# .bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
	. /etc/bashrc
fi

# Uncomment the following line if you don't like systemctl's auto-paging feature:
# export SYSTEMD_PAGER=

# User specific aliases and functions

root@topaz-1:/etc/skel>cat .bash_profile 
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
	. ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/.local/bin:$HOME/bin

export PATH

root@topaz-1:/etc/skel>cat .bashrc 
# .bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
	. /etc/bashrc
fi

# Uncomment the following line if you don't like systemctl's auto-paging feature:
# export SYSTEMD_PAGER=

# User specific aliases and functions

Solution

Thus to fix this, I would do the following assuming you have a default SLES based home area

For ".bashrc" in your home area (ie /home/{username}/.bashrc

  • Add the following lines
if [ -f /etc/redhat-release ]; then
    if [ -f /etc/bashrc ]; then
	    . /etc/bashrc
    fi
fi


Similarly for ".bash_profile" in your home area (ie /home/{username}/.bash_profile

  • Add the following lines
if [ -f /etc/redhat-release ]; then
    if [ -f ~/.bashrc ]; then
	    . ~/.bashrc
    fi
fi