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.

  1. Check existed environment variables

     echo $PATH
    

    You can find that PATH is a list of paths separated by :.

  2. Add environment variables temporarily

     export PATH=/dir/you/want/to/add:$PATH
    
  3. Add environment variables permanently

    Add the command export PATH=/dir/you/want/to/add:$PATH to ~/.bashrc, then restart the shell or source ~/.bashrc.

  4. 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
    
  5. 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>