java程序员经常需要配置JAVA_HOME。在windows下的环境变量的配置中,分用户变量和系统变量。 在linux系统,一般有一下几个可以配置的地方: /etc/profile
java程序员经常需要配置JAVA_HOME。在windows下的环境变量的配置中,分用户变量和系统变量。
在linux系统,一般有一下几个可以配置的地方:
/etc/profile #ubuntu 会引入所有profile.d/下的配置文件/etc/bashrc #ubuntu下是 /etc/bash.bashrc~/.bashrc~/.profile
其中:
- /etc下的是系统变量
- ~下的是用户变量
而bashrc和profile的区别,则需要理解shell的分类,详细可以参考http://www.linuxeye.com/Linux/bashrc-profile.html【1】
总结如下【2】:
- /etc/profile:此文件为系统的每个用户设置环境信息,当用户第一次登录时,该文件被执行.并从/etc/profile.d目录的配置文件中搜集shell的设置.
# /etc/profile
# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc
# It's NOT a good idea to change this file unless you know what you
# are doing. It's much better to create a custom.sh shell script in
# /etc/profile.d/ to make custom changes to your environment, as this
# will prevent the need for merging in future updates.
- /etc/bashrc:为每一个运行bash shell的用户执行此文件.当bash shell被打开时,该文件被读取.
# /etc/bashrc
# System wide functions and aliases
# Environment stuff goes in /etc/profile
# It's NOT a good idea to change this file unless you know what you
# are doing. It's much better to create a custom.sh shell script in
# /etc/profile.d/ to make custom changes to your environment, as this
# will prevent the need for merging in future updates.
- ~/.bashrc:该文件包含专用于你的bash shell的bash信息,当登录时以及每次打开新的shell时,该文件被读取.(每个用户都有一个.bashrc文件,在用户目录下)类似于/etc/bashrc,不需要重启生效,重新打开一个bash即可生效, /etc/bashrc对所有用户新打开的bash都生效,但~/.bashrc只对当前用户新打开的bash生效。
- ~/.profile:每个用户都可使用该文件输入专用于自己使用的shell信息,当用户登录时,该文件仅仅执行一次!默认情况下,他设置一些环境变量,执行用户的.bashrc文件.
参考:
【1】/etc/bashrc和/etc/profile区别 http://www.linuxeye.com/Linux/bashrc-profile.html
【2】/etc/bashrc,用户目录下.bashrc有什么区别? http://www.cnblogs.com/johnnyflute/p/3642021.html