Set environment variables in Linux
When you input a command, the system will search the executable file in the directories specified by the environment variable PATH
. If there are multiple directories containing the target file (e.g., multiple versions of the same software), the file in the directory with the highest priority will be executed.
-
Check existed environment variables
echo $PATH
You can find that
PATH
is a list of paths separated by:
. -
Add environment variables temporarily
export PATH=/dir/you/want/to/add:$PATH
-
Add environment variables permanently
Add the command
export PATH=/dir/you/want/to/add:$PATH
to~/.bashrc
, then restart the shell orsource ~/.bashrc
. -
Add/modify environment variables in conda (reference)
# set env vars `my_var` as `value` conda env config vars set my_var=value # check env vars in this env conda env config vars list # unset env vars in this env conda env config vars unset my_var -n test-env
-
use conda env in bash
# check the module name of miniconda/anaconda module load miniconda/3 source activate <env-name> # or # conda activate <env-name>
Enjoy Reading This Article?
Here are some more articles you might like to read next: