码迷,mamicode.com
首页 > 系统相关 > 详细

Linux 添加环境变量

时间:2018-06-13 17:23:20      阅读:189      评论:0      收藏:0      [点我收藏+]

标签:user   pat   col   环境   bash   export   ram   style   art   

  在用户目录下的.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 

 

Linux 添加环境变量

标签:user   pat   col   环境   bash   export   ram   style   art   

原文地址:https://www.cnblogs.com/shaosks/p/9178620.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!