Phenomenon
su <user>
After the command switches the user, it is actually not considered as a login behavior. At this time, it will be source ~/.bashrc
, but notsource ~/.bash_profile
detection
shopt login_shell
Determine whether the current shell is a login shell
plan
su - <user>
su -l <user>