linux 每次登陆时都需要 source ~/.bashrc 的问题

linux admin 1年前 (2023-02-17) 392次浏览 0个评论

问题

最近安装mysql,cmake,可能是修改了 ~ /.bash_profie 配置文件,导致每次登录服务器都需要source ~/.bashrc以激活环境变量,才可以执行如ls 等的基本操作

解决方法1:配置~/.bash_profile

vi ~/.bash_profie
查看是否有以下代码,加入代码后如下所示:

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ] ; then
        source .bashrc
fi

source ~/.bash_profile
关闭Xshell, 重新打开一个窗口,发现问题已解决。

解决方法2:配置~/.bashrc

vi ~/.bashrc

写入以下内容:

if [ -f /etc/bashrc ] ; then
   source .bashrc
fi 

 


原文:

https://www.jianshu.com/p/395bc4a939a8

https://www.cnblogs.com/iminifly/p/16618365.html


VPS小白 , 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:linux 每次登陆时都需要 source ~/.bashrc 的问题
喜欢 (0)
发表我的评论
取消评论
表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址