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

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?

$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

Related

Julia alias in .bashrc not working correctly

I am running Julia on my university's cluster, which runs Red Hat Linux. The Julia download's path is
/gsfs0/data/heathjo/Downloads/julia-1.5.3/bin
When I run
/gsfs0/data/heathjo/Downloads/julia-1.5.3/bin/julia
Julia runs fine. However, I just want to type
julia
And have it run. I edited my .bashrc to include
alias julia="/gsfs0/data/heathjo/Downloads/julia-1.5.3/bin/julia"
Running "julia", I now get the prompt
CORRECT>.julia (y|n|e|a)?
Running both .julia and julia results in
julia: Command not found.
What am I doing wrong? I also get the same issue when I try to set my path in the .bashrc file.
EDIT1: For reference, here's my .bashrc file :
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
module load gcc
module load torque
alias julia="/gsfs0/data/heathjo/Downloads/julia-1.5.3/bin/julia"
EDIT2: Here is my bash_profile as well, where I have tried adding it to my path. For some reason, I get the same error:
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
PATH=$PATH:$HOME/.local/bin:$HOME/bin
export PATH="/gsfs0/data/heathjo/Downloads/julia-1.5.3/bin:$PATH"
export PATH
Ideally, I'd like to just add it to my path rather than make an alias, but for some reason nothing seems to be working.

centos7 “export: command not found

I have followed a tutorial to install JDK 8 on my computer Centos7 OS, but in the last part I tried to set environment varibles.
In the last part of the tutorial I typed:
echo “export JAVA_HOME=/opt/jdk1.8.0_101” > /etc/profile.d/jre.sh
echo “export JRE_HOME=/opt/jdk1.8.0_101/jre” >> /etc/profile.d/jre.sh
echo “export PATH=$PATH:/opt/jdk1.8.0_101/bin:/opt/jdk1.8.0_101/jre/bin” >> /etc/profile.d/jre.sh
and then I am seeing this when I open the terminal:
bash: $'\342\200\234export':order not found
bash: $'\342\200\234export': order not found
bash: $'\342\200\234export': order not found
[evconsul8#localhost ~]$
Path:
[evconsul8#localhost ~]$ echo $PATH
/usr/lib64/qt-3.3/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:/home/evconsul8/.local/bin:/home/evconsul8/bin
After that I Trying to search the cause open
~/.bash_profile
[root#localhost evconsul8]# gedit ~/.bash_profile
Result:
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export JAVA_HOME=/opt/jdk1.8.0_101
export JRE_HOME=/opt/jdk1.8.0_101/jre
export PATH=$PATH:/opt/jdk1.8.0_101/bin:/opt/jdk1.8.0_101/jre/bin
export PATH
Note: In one of my attemps after the error I added manually the lines corresponding to JAVA_HOME, JRE_HOME and PATH=$PATH in the file above. It was ok??
The principal problem I guess it is causing troubles to other apps in my machine.
You should use regular double quotes (") to enclose a string and not the fancy ones (“) you are using.

All bash commands lost after sourcing bash_profile after osx upgrade

I recently upgraded my osx to os x el capitan. I noticed that subl command was missing so I tried adding the path to my bash_profile. It didn't work out so I removed it and then do a source ~/.bash_profile and now all of my bash commands are gone.
Here is my bash_profile file
export $PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
##
# Your previous /Users/judyngai/.bash_profile file was backed up as /Users/judyngai/.bash_profile.macports-saved_2013-06-27_at_16:30:58
##
# MacPorts Installer addition on 2013-06-27_at_16:30:58: adding an appropriate PATH variable for use with MacPorts.
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
# Finished adapting your PATH environment variable for use with MacPorts.
export PATH=/usr/local/sbin:$path
export PATH=/usr/local/bin:$PATH
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
:q!
and when I do export $PATH
I am getting this
31-34-238:bin judyngai$ export $PATH
-bash: export: `/usr/local/bin:/usr/local/sbin:': not a valid identifier
I cd into all of the directories that its getting searched through /usr/local/bin, /bin, /usr/local/bin etc. and saw all of the commands in there.
and this
31-34-238:~ judyngai$ source ~/.bash_profile
-bash: export: `/Users/judyngai/.rbenv/bin:/usr/local/bin:/usr/local/sbin:=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin': not a valid identifier
env: bash: No such file or directory
-bash: :q!: command not found
I actually think my bash_profile is fine so what is wrong? Rbenv and macport both look fine.
This line is destroying your path: export PATH=/usr/local/sbin:$path -- variables are case sensitive.
However, this error
-bash: export:`/usr/local/bin:/usr/local/sbin:': not a valid identifier
Indicates you probably have this in your bash_profile
export PATH=/usr/local/sbin:$path # PATH=/usr/local/sbin:
export PATH=/usr/local/bin:$PATH # PATH=/usr/local/bin:/usr/local/sbin:
export $PATH="$HOME/.rbenv/bin:$PATH"
# .....^
Where you are substituting the variable on the left-hand side instead of providing the variable name.
You export a variable (name), not a variable's value.

Cannot add environment variables in linux

For an entire day I have been tryng to add an environment variable to linux ad it isn't working. This is the guide that I am following. This is what is written in the .profile file.
# if running bash
if [ -n "$BASH_VERSION" ]; then
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
fi
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi
JAVA_HOME=/usr/local/java/jdk1.8.0_51
JRE_HOME=$JAVA_HOME/jre
LARAVEL=/home/user/.composer/vendor/bin
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin:$LARAVEL
export JAVA_HOME
export JRE_HOME
export LARAVEL
export PATH
I am running the file. But when I run echo $PATH I am not getting the $LARAVEL path. What am I doing wrong?
Have you logged out and logged in? Also try to update your .bashrc file instead. I think that .profile is only used for the ksh shell.
Try to source the file, like;
$ source yourfilename
In Unix/Linux (unlike in Windows) a program cannot affect the environment of the parent process. When you are running it as a regular shellscript it becomes a subprocess of the parent, and it will affect only it's own environment and not that of the parent.
Using the keyword source (or using the dot .) will instruct your process to executed the shell script directly rather than fork a new subprocess.
echo 'export PATH="$PATH":/path/to/folder/' >> ~/.bashrc
and
source ~/.bashrc

how to export environment variable with space in cygwin

when I export the environment variable :
$ export VS_PATH=/cygdrive/c/Users/bla/Documents/Visual\ Studio\ 2010/Projects/
and echo $VS_PATH gives the correct variable,
$ echo $VS_PATH
/cygdrive/c/Users/bla/Documents/Visual Studio 2010/Projects/
so I thought it is set correctly.But
$ cd $VS_PATH
-bash: cd: /cygdrive/c/Users/bla/Documents/Visual: No such file or directory
what is the problem? How could I export and cd it correctly
Because the cd command is reading the variable as is, meaning the exact same way you see it when you echo it. It'll work fine if you put the var in quote marks.
$ cd "$VS_PATH"

Resources