本文主要是介绍解决Linux每次开启新会话不自动执行 ~/.bashrc 的问题,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
问题原因
系统中缺少 .bash_profile
文件。
解决方案
1. 创建 .bash_profile
文件
使用以下命令创建 .bash_profile
文件:
vim ~/.bash_profile
2. 添加脚本内容
将以下脚本内容复制并粘贴到 .bash_profile
文件中:
# if running bash
if [ -n "$BASH_VERSION" ]; then# include .bashrc if it existsif [ -f "$HOME/.bashrc" ]; then. "$HOME/.bashrc"fi
fi# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; thenPATH="$HOME/bin:$PATH"
fi# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/.local/bin" ] ; thenPATH="$HOME/.local/bin:$PATH"
fi
重新打开会话
保存并关闭 .bash_profile
文件后,重新打开一个新的终端会话即可。
这篇关于解决Linux每次开启新会话不自动执行 ~/.bashrc 的问题的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!