How do you configure environment variables in Centos?
To set up environment variables in CentOS, you can follow these steps:
- Open the terminal and log in to the CentOS system as an administrator.
- Open the file /etc/profile with a text editor, such as vi editor: sudo vi /etc/profile.
- 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
- Save and close the file.
- Run the following command to make the configuration take effect: source /etc/profile.
- 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.