Home  >  Article  >  Operation and Maintenance  >  How to set environment variables in linux

How to set environment variables in linux

王林
王林Original
2020-05-15 13:58:494296browse

How to set environment variables in linux

There are three ways to set environment variables:

1. Temporary

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:new_path_name

where new_path_name is the new path. This is only valid for the current shell. It disappears after restarting.

2. Permanent

vim /etc/profile
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:new_path_name
source /etc/profile

Global environment variables will not disappear after restarting and are valid for all users.

3. Permanent

~/.bashrc
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:new_path_name
source .bashrc

Global environment variables will not disappear after restarting, but are only valid for the currently logged in user.

Recommended tutorial: linux tutorial

The above is the detailed content of How to set environment variables in linux. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn