linux下通过su命令切换用户后,~/.bash_profile配置不生效

现象

su <user> 命令切换用户后,其实不算做登录行为,此时会 source ~/.bashrc,而不会source ~/.bash_profile

检测

shopt login_shell
判断当前shell是否是登录shell

方案

su - <user>
su -l <user>

参考

参考1
参考2

猜你喜欢

转载自blog.csdn.net/qq_34507736/article/details/131642375