centos7 “export: command not found - linux

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.

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.

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?
$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

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

Update .bashrc from provisioning shell script with Vagrant

I'm trying to add some additional lines to .bashrc in my home directory from the provisioning shell script when launching a new instance with Vagrant.
In the shell script I have:
set -x
sudo apt-get update
sudo apt-get install vim
echo "source /usr/local/share/chruby/chruby.sh">> ~/.bashrc
echo "source /usr/local/share/chruby/auto.sh">> ~/.bashrc
However after completion nothing has been written to .bashrc.
This is a cut down version of the full script the intention of which is to install Ruby/Rails.
You need to give the full path to the file.
E.g.
echo "source /usr/local/share/chruby/chruby.sh" >> /home/vagrant/.bashrc
Add these lines to .bashrc
if [ -f /usr/local/share/chruby/chruby.sh ]; then
. /usr/local/share/chruby/chruby.sh
fi
It will textually include the script into .bashrc and execute it when opening a new shell.
Try this for your last 2 lines - it should give you exactly what you need.
echo "source /usr/local/share/chruby/chruby.sh" >> /home/vagrant/.bashrc
echo "source /usr/local/share/chruby/auto.sh" >> /home/vagrant/.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