将环境变量写入.profile
以设置golang环境变量为例
#GOROOT is the location where Go package is installed on your system. export GOROOT=/usr/local/go #GOPATH is the location of your work directory. For example my project directory is ~/Projects/Proj1 . export GOPATH=$HOME/Projects/Proj1 #Now set the PATH variable to access go binary system wide. export PATH=$GOPATH/bin:$GOROOT/bin:$PATH
将上述变量写入.profile
使环境变量生效
$ source ~/.profile