1. 程式人生 > >Linux 添加環境變量

Linux 添加環境變量

ech bashrc chrome style 環境 programs fun ive bin

  在用戶目錄下的.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 添加環境變量