How Do I Set an Environment Variable in Linux Bash?
Contents the Easiest Way to Set Environment Variables in Bash Is to Use the “Export” Keyword Followed by the Variable Name, an Equal Sign and the Value to Be...
Contents
The easiest way to set environment variables in Bash is to use the “export” keyword followed by the variable name, an equal sign and the value to be assigned to the environment variable.
How do I set environment variables in bash?
3.2 How to Set an Environment Variable Permanently in Bash Shell
- Use ” printenv ” (or ” env “) to list all the environment variables.
- Use ” setenv varname value ” and ” unsetenv varname ” to set and unset an environment variable.
How do I set an environment variable in Linux terminal?
To make an environment persistent for a user’s environment, we export the variable from the user’s profile script.
- Open the current user’s profile into a text editor. vi ~/.bash_profile.
- Add the export command for every environment variable you want to persist. export JAVA_HOME=/opt/openjdk11.
- Save your changes.