[英]Bash_profile file editing
I am using CentOS. 我正在使用CentOS。 I installed Java8 from the rpm. 我从rpm安装了Java8。
Following the tutorial I did this: 在本教程之后,我这样做了:
export JAVA_HOME=jdk-install-dir 导出JAVA_HOME = jdk-install-dir
export PATH=$JAVA_HOME/bin:$PATH 导出PATH = $ JAVA_HOME / bin:$ PATH
However, when I disconnect from SSH it has gone. 但是,当我断开与SSH的连接时,它已经消失了。 How can I save the above into the .bash_profile? 如何将以上内容保存到.bash_profile? I believe this is the best way to resolve this problem. 我相信这是解决此问题的最佳方法。
Following this tutorial: 遵循本教程:
https://docs.oracle.com/cd/E19182-01/820-7851/inst_cli_jdk_javahome_t/ https://docs.oracle.com/cd/E19182-01/820-7851/inst_cli_jdk_javahome_t/
Thanks! 谢谢!
If you want to set an environment variable permanently, you can write the export
command line to /etc/profile.d/ (for system wide change) or ~/.bash_profile (for local user). 如果要永久设置环境变量,可以将export
命令行写入/etc/profile.d/(用于系统范围更改)或〜/ .bash_profile(用于本地用户)。
NOTE: bashrc will be executed whenever a new terminal is opened (AFTER there is a logged in user). 注意:每当打开新终端时(在有登录用户之后)将执行bashrc。
bash_profile will be executed whenever a user is logging in (no matter is it's via ssh or actually sitting in front of the computer) 无论何时用户登录(无论是通过ssh还是实际坐在计算机前),都会执行bash_profile
You can always export the envvars in one file and by sourcing this file in the other file you will have those envvars in both login/non-login shells: 您始终可以将envvars导出到一个文件中,而通过在另一个文件中获取该文件,则可以在登录/非登录shell中使用这些envvars:
#If you exported the envvars in bash_profile
if [ -f ~/.bashrc ]; then
source ~/.bashrc
fi
Hope it helps you 希望对您有帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.