设置环境变量有以下三种方式:
1、临时的
export ld_library_path=$ld_library_path:new_path_name
其中new_path_name为新增的路径。这个只对当前shell有效。重启即消失。
2、永久的
vim /etc/profileexport ld_library_path=$ld_library_path:new_path_namesource /etc/profile
全局的环境变量,重启不消失,对所有用户有效。
3、永久的
~/.bashrcexport ld_library_path=$ld_library_path:new_path_namesource .bashrc
全局的环境变量,重启不消失,但是只对当前登录用户有效。
推荐教程:linux教程
以上就是linux如何设置环境变量的详细内容。