How To Set Environment Variable On 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.
1. Using the export command:
Open the terminal and run the following command to set environment variables:
export VAR_NAME=”value”
Replace “VAR_NAME” with the name of the environment variable you want to set, and “value” with the value you want to assign to it.
2. Using the /etc/profile file:
Open the /etc/profile file using your favorite text editor.
Add the following line at the end of the file to set an environment variable:
export VAR_NAME=”value”
Replace “VAR_NAME” with the name of the environment variable you want to set, and “value” with the value you want to assign to it.
Save the file and close it.
3. Using the /etc/environment file:
Open the /etc/environment file using your favorite text editor.
Add the following line at the end of the file to set an environment variable:
VAR_NAME=”value”
Replace “VAR_NAME” with the name of the environment variable you want to set, and “value” with the value you want to assign to it.
Save the file and close it.