How To Set Environment Variables 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. Use the export command.
To set a global environment variable, open the terminal and type:
export VARNAME=”value”
where VARNAME is the name of the environment variable and “value” is the value you want to set it to.
2. Create a configuration file.
You can also set environment variables by creating a configuration file. This file must be named .bash_profile and be placed in your home directory. To create the file and set the environment variable, open the terminal and type:
touch .bash_profile
echo “export VARNAME=’value'” >> .bash_profile
where VARNAME is the name of the environment variable and “value” is the value you want to set it to.
3. Use the command line.
You can also set environment variables directly on the command line. To do this, open the terminal and type:
VARNAME=”value”
where VARNAME is the name of the environment variable and “value” is the value you want to set it to.