After switching users through the su command under Linux, the ~/.bash_profile configuration does not take effect

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>

reference

Reference 1
Reference 2

Guess you like

Origin blog.csdn.net/qq_34507736/article/details/131642375