How do you configure environment variables in Centos?

To set up environment variables in CentOS, you can follow these steps:

  1. Open the terminal and log in to the CentOS system as an administrator.
  2. Open the file /etc/profile with a text editor, such as vi editor: sudo vi /etc/profile.
  3. Add the following content to the end of the file to set up environment variables:
export JAVA_HOME=/usr/java/jdk1.8.0_291   # 替换为实际的Java安装路径
export PATH=$PATH:$JAVA_HOME/bin
  1. Save and close the file.
  2. Run the following command to make the configuration take effect: source /etc/profile.
  3. Check if the environment variables are configured correctly: run ‘echo $JAVA_HOME’ to output the Java installation path and ‘echo $PATH’ to output the environment variables.

After completing the above steps, the environment variables have been successfully configured in the CentOS system.

bannerAds