GS.
GS.

Reputation: 83

linux bash error: -bash: No such file or directory

After I login to Linux every time, it shows : -bash: /usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/xx/bin: No such file or directory

I notice that there is a '=' in it, but I don't know why. My .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 JAVA_HOME=/opt/jdk1.8.0_73
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

I want to set the JAVA environment , and it works ,but after I edit profile,it shows the bash error. How could I fix it?

Upvotes: 0

Views: 3671

Answers (1)

Roman
Roman

Reputation: 6656

$PATH=$PATH:$HOME/bin does not do what you want. After substituting the values for variables (PATH=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin and HOME=/home/xx) it executes a command:

/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/xx/bin

which explains the error. To do a variable assignment, remove $ from variable name on the left side of the assignment:

PATH=$PATH:$HOME/bin

Upvotes: 2

Related Questions