清除Linux上的echo $ PATH

时间:2015-09-26 11:42:02

标签: linux bash path environment-variables

我正在努力完全理解我的centos os上的路径设置。我确保总是在.bashrc中设置我需要的东西,但是当我运行echo $PATH时,我得到了大量的东西和重复我不想要部分路径。它是从哪里得到的,如何清理其中的所有内容,只反映我正在放入的内容.bashrc。这也导致我的系统读取我不希望它找到的二进制文件,因为它位于echo $PATH中。以下是echo $PATH的完整结果:

PATH=/opt/jdk1.8.0_60/bin:/opt/jdk1.8.0_60/jre/bin:/usr/local/bin:/usr/bin:/usr/local/maven/bin:/ebs/wfx-etl/scripts:/ebs/config:/usr/local/go/bin:/ebs/spark1.5/bin:/opt/jdk1.8.0_60/bin:/opt/jdk1.8.0_60/jre/bin:/usr/local/bin:/usr/bin:/usr/local/maven/bin:/ebs/wfx-etl/scripts:/ebs/config:/usr/local/go/bin:/ebs/spark1.5/bin:/opt/jdk1.8.0_60/bin:/opt/jdk1.8.0_60/jre/bin:/usr/local/bin:/usr/bin:/usr/local/maven/bin:/ebs/wfx-etl/scripts:/ebs/config:/usr/local/go/bin:/ebs/spark1.5/bin:/opt/jdk1.8.0_60/bin:/opt/jdk1.8.0_60/jre/bin:/usr/local/bin:/usr/bin:/usr/local/maven/bin:/ebs/wfx-etl/scripts:/ebs/config:/usr/local/go/bin:/ebs/spark1.5/bin:/opt/jdk1.8.0_60/bin:/opt/jdk1.8.0_60/jre/bin:/usr/local/bin:/usr/bin:/usr/local/maven/bin:/ebs/wfx-etl/scripts:/ebs/config:/usr/local/go/bin:/ebs/spark1.5/bin:/ebs/anaconda3/bin:/opt/jdk1.8.0_60/bin:/opt/jdk1.8.0_60/jre/bin:/usr/local/bin:/usr/bin:/usr/local/maven/bin:/ebs/wfx-etl/scripts:/ebs/config:/usr/local/go/bin:/ebs/spark1.5/bin:/usr/local/rvm/gems/ruby-1.9.3-p551/bin:/usr/local/rvm/gems/ruby-1.9.3-p551@global/bin:/usr/local/rvm/rubies/ruby-1.9.3-p551/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/rvm/bin

这就是我在.bashrc中的内容:

export SBT_HOME=/usr/local/sbt
export R_HOME=/usr/local/R-3.1.2
export JAVA_HOME=/opt/jdk1.8.0_60
export JRE_HOME=/opt/jdk1.8.0_60/jre
export M2_HOME=/usr/local/maven
export SPARK_HOME=/ebs/spark1.5
export PATH=${JAVA_HOME}/bin:${JRE_HOME}/bin:/usr/local/bin:/usr/bin:${M2_HOME}/bin:/ebs/wfx-etl/scripts:/ebs/config:/usr/local/go/bin:${SPARK_HOME}/bin:$PATH
export PATH=/ebs/anaconda3/bin:$PATH
export PGPASSFILE=$HOME/.pgpass.conf
export EDITOR=vim

2 个答案:

答案 0 :(得分:1)

您可以在.bashrc中完全覆盖它,如下所示:

export PATH=/foo/bar:/baz/quux

替换您喜欢的任何路径,但如果您错过了/bin/usr/bin,请注意,您会感到抱歉。

答案 1 :(得分:0)

Java delevopment kit(jdk)设置了所有这些路径。 我认为这很有用。对于python你也有anaconda 3。

或者您可以使用env -i与bash / zsh共进午餐以设置空白环境

env -i bash

env -i zsh