返回
Featured image of post ssh登录环境变量不生效

ssh登录环境变量不生效

问题描述

ssh登录服务器,环境变量不生效(一些命令找不到,即使已经写入了bashrc)

问题解决

ssh登录服务器时,有时不会执行.bashrc,而是执行.bash_profile

只需要添加.bash_profile文件即可

if [ -n "$BASH_VERSION" ]; then
    # include .bashrc if it exists
    if [ -f "$HOME/.bashrc" ]; then
        . "$HOME/.bashrc"
    fi
fi

环境变量依然写在.bashrc

Built with Hugo
主题 StackJimmy 设计