美文网首页
Mac下创建.bash_profile

Mac下创建.bash_profile

作者: O无为学长O | 来源:发表于2020-12-26 12:14 被阅读0次

.bash_profile 是用户登陆时的环境变量,如PATH等的设置 。当用户登录后,系统会执行此文件,以设置相应环境。

.bash_profile 文件默认不存在,需要自己在用户目录下创建。

$  cd ~     # 进入用户主目录
$  touch .bash_profile  # 创建 .bash_profile 文件

创建之后可以使用下面命令通过文本编辑器打开

$ open -e .bash_profile  # 使用文本编辑器打开  .bash_profile 文件

打开之后里面就可以进行各种配置了,比如将 mongodb 的 bin 目录添加到环境变量中
export PATH=${PATH}:/usr/local/MongoDB/bin

8479446-b9a138946c895cd9.png
编辑并保存好之后,需要执行以下命令让配置生效:
$ source .bash_profile

相关文章

网友评论

      本文标题:Mac下创建.bash_profile

      本文链接:https://www.haomeiwen.com/subject/jilonktx.html