sudo 添加配置环境变量

sudo –preserve-env=HOME /usr/bin/env

Finally you can also set environment variables directly in the sudo command, like this:

sudo ZEBRA=true /usr/bin/env

sudo LD_LIBRARY_PATH=/opt/intel/mkl/lib/ia32:$LD_LIBRARY_PATH LD_PRELOAD=/opt/intel/mkl/lib/ia32/libmkl_core.so python -c “import numpy”

参考

  1. https://www.petefreitag.com/item/877.cfm
  2. https://askubuntu.com/questions/57915/environment-variables-when-run-with-sudo