Linux 添加环境变量

  在用户目录下的.bash_profile文件中增加变量
  用vi在用户目录下的.bash_profile文件中增加变量,改变量仅会对当前用户有效,并且是“永久的”。

  vim /root/.bash_profile  

  

  

  

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin

export PATH
export CHROMECHROME_HOME=/usr/bin/chromedrive
export PATH=$PATH:$CHROMECHROME/MYSQL_HOME/bin
export MONGO_DB=/usr/local/mongodb
export PATH=$PATH:$MONGO_DB/bin
~                                    

  要让刚才的修改马上生效,需要在用户目录下执行以下代码:

  source /etc/profile

  

  针对所有用户:

  在/etc/profile文件中添加变量
  用vi在文件/etc/profile文件中增加变量,该变量将会对Linux下所有用户有效,并且是“永久的”。

  要让刚才的修改马上生效,需要执行以下代码

  source /etc/profile 

猜你喜欢

转载自www.cnblogs.com/shaosks/p/9178620.html
今日推荐