I've got an installation of CentOS 7 where /bin/sh is a symbolic link to bash. However they behave differently when using sudo. For example with 'sudo sh': [centos@ip-xx.xx.xx.xx ~]$ sudo shsh-4.2# echo $PATH/sbin:/bin:/usr/sbin:/usr/binWith 'sudo bash': [centos@ip-xx.xx.xx.xx ~]$ sudo bash[root@ip-xx.xx.xx.xx centos]# echo $PATH/opt/puppetlabs/puppet/bin:/sbin:/bin:/usr/sbin:/usr/binThe extra PATH element comes from a /etc/profile.d/-script. Why isn't it showing up with 'sudo sh'?
Why doesn't 'sudo sh' source profile.d scripts
linux;bash;shell;centos
~/.bashrc sources /etc/bashrc, that then sources /etc/profile.d/* (but not /etc/profile?).  I don't know if this confusing behaviour is specific to Redhat derived systems, or not.~/.bashrc is sourced by bash when run as a non-login shell.  (For when it's run as a login shell, the bash docs suggest you need to make sure ~./bashrc is sourced manually in your ~/.bash_profile).But when you run sh, ~/.bashrc is not sourced.  sh does not source anything unless run as a login shell.One possible way to avoid this confusion is if you prefer sudo -i, which runs a login shell.  The shell used is chosen based on the shell of the target user (i.e. root by default).