如何自动获取 .profile

All*_*Eer 2 unix

我添加到 ~/.profile 中的路径,如果我将更新路径

source ~/.profile
Run Code Online (Sandbox Code Playgroud)

但在系统重新启动时, ~/.profile 未加载。我怎样才能让它自动,所以我不必采购它?~/.profile 是添加到诸如 grails bin 之类的路径的正确位置吗?

Nic*_*ton 5

您需要bash使用其中之一进行调用-l--login使其成为登录 shell,一个查找和读取~/.profile. 有关更多信息,请参阅 中的INVOCATION部分man bash

如果您bash每次都想运行某些内容,而不仅仅是在将其设置为登录 shell 时,请将其放入~/.bashrc, 而不是~/.profile.

如果你想决定什么应该去哪里,把可以继承的东西,例如环境变量设置放入~/.profile和不能继承的东西,比如alias定义放入~/.bashrc.