A couple of things: First, like the commenter @Artem S. Tashkinov says, (in some shells) the export PATH
needs to be on a new line since it's a separate command. It's saying set the new PATH
as an environment variable. An environment variable is a variable (a dynamic value) which is used not only by one program, but the whole environment. As a simplification, think environment = shell (corrected thanks to ilkkachu).
Secondly, to more directly answer your question, $PATH
is an environment variable which stores the locations of executables (programs). You are simply appending /usr/local/openmpi-3.0.0/bin
to $PATH
, so that if you type mpirun
in a terminal, the shell knows it lives in /usr/local/openmpi-3.0.0/bin
and can run it. The part before the colon is the contents of $PATH
already; the colon means 'append what follows to what preceded'; and the /usr/local/openmpi-3.0.0/bin
is the thing to append.
You may ask, why do I need the dollar? The simple answer is that the shell references variables that have already been defined with a $. For example, if I run:
NAME='BOB'
echo $NAME
the shell would print BOB
, whereas
echo NAME
would result in the shell printing NAME
.
Finally, you don't want to just change $PATH
to the home of your executable (as opposed to appending), otherwise the system wouldn't know where other programs live.
export PATH
must start from a new line. – Artem S. Tashkinov Nov 26 '22 at 16:06.bashrc
which is located in your home directory. – doneal24 Nov 26 '22 at 16:42./bashrc
, and the$which mpirun
(rather than$ which mpirun
), also suggest transcription errors (although, yes, the message might really look like that). – G-Man Says 'Reinstate Monica' Jan 18 '23 at 18:34./bashrc
part. Anyway, I think I was just surprised that it did work when I tried it. – ilkkachu Jan 18 '23 at 19:08