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:

  1. The bash configuration file located in the home directory.
vi ~/.bashrc
  1. 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
  1. Press the Esc key, then type :wq to save and exit the file.
  2. Execute the following command to apply the configuration:
source ~/.bashrc
  1. 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.

广告
Closing in 10 seconds
bannerAds