This problem drives me nuts. It is working in all my RHEL systems, but on Ubuntu20LTS I cannot get it to work properly.
The configuration:
The environment-modules are loaded via a script in "/etc/profile.d" for all users when they open a terminal/konsole. The module "aliases" defines aliases for all our projects and all users shall see those aliases in their environment. As I learned, the terminal/konsole will open "interactive non-login-shells". I our configuration, the ".bashrc" is sourced when the terminal/konsole is opened.
What is expected and working on RHEL, but not working on Ubuntu20LTS:
Open terminal or konsole --> modules are loaded (via script in “etc/profile.d/…”) --> “alias” shows all defined aliases from module “aliases” (see the ".bashrc" content at the end of this post) :
I am .bashrc and was loaded!
[INFO:] $MODULEPATH=/icd/cfg/modules:
Currently Loaded Modulefiles:
- aliases 2) common 3) aliases_ue
[userXY@host:~]
alias
alias ATIC183='cd $ICD_PROJ/ATIC183; source $ICD_CFG/env/proj_setup/start_proj.sh'
alias FFT='cd $ICD_PROJ/monarch; source $ICD_CFG/env/proj_setup/start_proj.sh'
alias HXLR0='cd $ICD_PROJ/HXLR0; source $ICD_CFG/env/proj_setup/start_proj.sh'
What is experienced on Ubuntu20LTS:
Open terminal --> modules are loaded --> “alias” does NOT show the defined aliases, only the one definition from ".bashrc":
I am .bashrc and was loaded!
[INFO:] $MODULEPATH=/icd/cfg/modules:
Currently Loaded Modulefiles:
- aliases 2) common 3) aliases_ue
[userXY@host:~]
alias
alias ll='ls -al'
What has been tested in addition and does NOT work:
Open terminal --> reload module via “module load aliases” --> “alias” does NOT show the defined aliases
Open terminal --> “su userXY” --> modules are loaded --> “alias” does NOT show the defined aliases
# su userXY
Password:
I am .bashrc and was loaded!
[INFO:] $MODULEPATH=/icd/cfg/modules:
Currently Loaded Modulefiles:
- aliases 2) common 3) aliases_ue
[userXY@host:~]
alias
alias ll='ls -al'
Open terminal --> “bash -l” --> modules are loaded --> “alias” does NOT show the defined aliases, but other aliases are loaded in addition
Open terminal --> “su userXY” --> modules are loaded --> “bash -l” --> alias” does NOT show the defined aliases, but other aliases are loaded in addition
# bash -l
I am .bashrc and was loaded!
[INFO:] $MODULEPATH=/icd/cfg/modules:
Currently Loaded Modulefiles:
- aliases 2) common 3) aliases_ue
[userXY@host:~]
alias
alias ll='ls -al'
alias pat='puppet agent -t'
alias su2='sudo su -'
Open terminal --> “sudo su userXY” --> NO modules are loaded
# sudo su userXY
ERROR: No module path defined
ERROR: No module path defined
I am .bashrc and was loaded!
[INFO:] $MODULEPATH=
No Modulefiles Currently Loaded.
What is working to get the aliases:
Open terminal --> “sudo su userXY” --> NO modules are loaded --> “bash -l” --> alias shows all defined aliases
Open terminal --> ssh localhost --> modules are loaded --> alias shows all defined aliases
# sudo su userXY
ERROR: No module path defined
ERROR: No module path defined
I am .bashrc and was loaded!
[INFO:] $MODULEPATH=
No Modulefiles Currently Loaded.
[userXY@host:~]
bash -l
I am .bashrc and was loaded!
[INFO:] $MODULEPATH=/icd/cfg/modules:
Currently Loaded Modulefiles:
- aliases 2) common 3) aliases_ue
[userXY@host:~]
alias
alias ATIC183='cd $ICD_PROJ/ATIC183; source $ICD_CFG/env/proj_setup/start_proj.sh'
alias FFT='cd $ICD_PROJ/monarch; source $ICD_CFG/env/proj_setup/start_proj.sh'
alias HXLR0='cd $ICD_PROJ/HXLR0; source $ICD_CFG/env/proj_setup/start_proj.sh'
Its seems it has to do with the login and non-login shells. But I cannot find out why the aliases (which are defined by the loaded modules) are overwritten/deleted in the one scenario, but are available in the other scenario.
Those are config-files in my $HOME:
.bash_aliases --> not existent
.profile --> not existent
.login --> not existent
.cshrc --> not existent
.bashrc
#cat .bashrc
case "$0" in
-sh|sh|/sh) modules_shell=sh ;;
-ksh|ksh|/ksh) modules_shell=ksh ;;
-zsh|zsh|/zsh) modules_shell=zsh ;;
-bash|bash|/bash) modules_shell=bash ;;
esac
module() { eval /usr/bin/tclsh8.6 /usr/lib/x86_64-linux-gnu/modulecmd.tcl $modules_shell $*; }
.bashrc
Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
Uncomment the following line if you don't like systemctl's auto-paging feature:
export SYSTEMD_PAGER=
User specific aliases and functions
export SVN_EDITOR=vi
#colorized shell prompt
export PS1='[[\033[1;31m]\u@[\033[1;34m]\h:[\033[0;32m]\w[\033[0m]]\n# '
load aliases
module load aliases_ue
#disable beep
xset b off
alias ll="ls -al"
echo "I am .bashrc and was loaded!"
echo -e "[INFO:] $MODULEPATH=$MODULEPATH\n"
module list
.bash_profile
# 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
.kshrc
# cat .kshrc
# .kshrc
Source global definitions
if [ -f /etc/kshrc ]; then
. /etc/kshrc
fi
use emacs editing mode by default
set -o emacs
User specific aliases and functions
Any hint is very much appreciated !