How to configure multiple environment variables in Linux?
To set up multiple environment variables in a Linux system, you can edit the ~/.bashrc or ~/.bash_profile file. Here are the steps to configure multiple environment variables:
- The bash configuration file located in the home directory.
vi ~/.bashrc
- Add the definition of environment variables at the end of the file, for example:
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
export PATH=$JAVA_HOME/bin:$PATH
export ENV_VAR=value
- Press the Esc key, then type :wq to save and exit the file.
- Execute the following command to apply the configuration:
source ~/.bashrc
- Can you please tell me the value of the JAVA_HOME variable?
To temporarily set environment variables, you can directly input the export command in the terminal, for example:
export MY_VAR=value
These environment variables are only effective in the current terminal session.