Home >Operation and Maintenance >Linux Operation and Maintenance >How to add environment variables in linux

How to add environment variables in linux

王林
王林forward
2023-06-02 20:52:096028browse

The first method: (valid temporarily, invalid after restarting)

export PATH=/usr/local/webserver/mysql/bin:$PATH

The second method: (valid permanently)

Edit /etc/profile file:

vim /etc/profile

Add the following configuration at the end of the file:

export JAVA_HOME=/usr/local/jdk-12/
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin

The source command reloads the /etc/profile file so that the modified content is valid in the current shell window:

source /etc/profile

What versions of Linux are there?

Linux versions include: Deepin, UbuntuKylin, Manjaro, LinuxMint, Ubuntu and other versions. Among them, Deepin is one of the best-developed Linux distributions in China; Ubuntu Kylin is a derivative distribution based on Ubuntu; Manjaro is a Linux distribution based on Arch; LinuxMint's default Cinnamon desktop is similar to Windows XP and is simple and easy to use; Ubuntu is a desktop application Mainly Linux operating system.

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

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete