How To Set Environment Variable Linux?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can set an environment variable in Linux by using the `export` command. For example, to set an environment variable named `MYVAR` with the value “testing”, you would run the following command:
`export MYVAR=”testing“`
To view the value of the environment variable, you can use the `echo` command:
`echo $MYVAR`
The output should be “testing“.
1. Open the file /etc/environment using a text editor.
2. Add the environment variable at the end of the file in the following format:
VARIABLE_NAME=value
3. Save the file and exit the text editor.
4. To reload the changes, run the following command:
source /etc/environment
5. To check if the variable was correctly set, run the following command:
echo $VARIABLE_NAME