How To Set An 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.
1. Open the terminal window by pressing ctrl+alt+t.
2. Enter the command “export” followed by the environment variable name and value. For example, export MYVAR=myvalue.
3. To save the environment variable permanently, add the command to the end of the ~/.bashrc file.
4. Source the ~/.bashrc file by entering the command “source ~/.bashrc”. This will update the environment variables and make them available in the current session.
5. Verify the environment variable is set by entering the command “echo $MYVAR”. The value of the environment variable should be outputted to the terminal.