What are the steps for configuring environment variables in CentOS 7?
The steps to configure environment variables in CentOS 7 are as follows:
- Open the terminal and log in to the CentOS 7 system.
- Open the ~/.bashrc file using a text editor, such as vi or nano. You can open the file using the following command:
vi ~/.bashrc
- Add the desired environment variables at the end of the file, for example:
export PATH=$PATH:/usr/local/bin
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.191.b12-1.el7_6.x86_64
export MAVEN_HOME=/usr/share/maven
Make sure to set the PATH variable to the original value plus the new path.
- Save and close the file. Press the Esc key in the vi editor, type :wq, and then press Enter to save and close the file.
- To activate the new environment variable, use the following command:
source ~/.bashrc
- Check if the environment variables have been set successfully. You can view the values of the environment variables using the following command:
echo $JAVA_HOME
echo $MAVEN_HOME
If the output matches the value you have set, it indicates that the environment variable has been successfully configured.
- You can now use the new environment variable in the system.
More tutorials
Comprehending Java’s Data Types(Opens in a new browser tab)
Reading and Writing data using Python(Opens in a new browser tab)
How can I check the data storage location of Redis?(Opens in a new browser tab)
How to set up a C++ environment in Visual Studio Code?(Opens in a new browser tab)
How to set up a C++ environment in Visual Studio Code?(Opens in a new browser tab)
How to create a cpp file in vscode?(Opens in a new browser tab)