欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

linux环境变量设置

程序员文章站 2022-06-03 21:34:46
...

参考:linux 环境变量设置方法总结(PATH/LD_LIBRARY_PATH)
https://blog.csdn.net/wangeen/article/details/8159500

查看当前环境变量:
echo $PATH

1,临时修改,当前终端有效
添加库搜索路径
export LD_LIBRARY_PATH=/usr/local/cuda-8.0/lib64

2,用户级别修改
 sudo vi ~/.bashrc
 #export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-9.0/lib64
 #export PATH=$PATH:/usr/local/cuda-9.0/bin
 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-8.0/lib64
 export PATH=$PATH:/usr/local/cuda-8.0/bin
 
 source .bashrc  (source执行刚修改的初始化文件,使之立即生效,而不必注销并重新登录)


3,系统级别修改,针对系统所有用户的全局变量
sudo vi /etc/profile
PATH=/usr/local/cuda-9.0/bin:$PATH
export PATH 
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-9.0/lib64
export LD_ LIBRARY_PATH

source /etc/profile   使立即生效