环境 centos7
Linux中含有两个重要的文件 /etc/profile和$HOME/.bash_profile 每当系统登陆时都要读取这两个文件,用来初始化系统所用到的变量,其中/etc/profile是超级或所有的用户所用,$HOME/.bash_profile是每个用户自己独立的
# /etc/profile
# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc
# 用于登录设置函数和别名的系统范围环境和启动程序位于/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/profile.d/中创建一个custom.sh shell脚本,
# 以便对您的环境进行自定义更改,因为这样可以避免在将来的更新中进行合并。
# 1. 首先定义了pathmunge函数, 该函数对环境变量PATH, 进行追加相关路径操作.
pathmunge () {
case ":${
PATH}:" in
*:"$1":*) # a regular expression
;; # do nothing
*) # 表示其他所有值
if [ "$2" = "after" ] ; then
PATH=$PATH:$1