ubuntu配置环境变量

来源:互联网 发布:怖客用哪个软件可以看 编辑:程序博客网 时间:2024/06/06 03:18

1.打开终端

ctrl+alt+t

2.打开配置文件

sudo nano /etc/profile

3.修改配置文件

下面是我配置的scala,spark,maven的环境变量

# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).

if [ "$PS1" ]; then
  if [ "$BASH" ] && [ "$BASH" != "/bin/sh" ]; then
    # The file bash.bashrc already sets the default PS1.
    # PS1='\h:\w\$ '
    if [ -f /etc/bash.bashrc ]; then
      . /etc/bash.bashrc
    fi
  else
    if [ "`id -u`" -eq 0 ]; then
      PS1='# '
    else
      PS1='$ '
    fi
  fi
fi

# The default umask is now handled by pam_umask.
# See pam_umask(8) and /etc/login.defs.

if [ -d /etc/profile.d ]; then
  for i in /etc/profile.d/*.sh; do
    if [ -r $i ]; then
      . $i
    fi
  done
  unset i
fi
export SCALA_HOME=/spark/scala-2.10.5
export PATH=$PATH:$SCALA_HOME/bin

export SPARK_HOME=/spark/spark-1.6.1-bin-hadoop2.6
export PATH=$PATH:$SPARK_HOME/bin


4 重启电脑

先运行下配置文件(点空格/etc/profile).然后运行命令。

如果不行,就重启电脑。

1 0