How To Set Environment Variables In 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.
To set environment variables in Linux, open the terminal and type the following command:
export VARIABLE_NAME=value
where VARIABLE_NAME is the name of the environment variable and value is the value to be assigned to it.
For example, if you want to set the environment variable PATH, you would type the following command:
export PATH=/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin
You can also use the command line to set multiple environment variables at once. To do so, you would type:
export VARIABLE_NAME_1=value_1 VARIABLE_NAME_2=value_2 VARIABLE_NAME_3=value_3
You can also set environment variables permanently in Linux by adding them to the .bashrc file in your home directory. To do so, open the .bashrc file in a text editor and add the following line:
export VARIABLE_NAME=value