To create an environment variable in a Linux shell, you can follow these steps:
-
Open your terminal.
-
Use the
exportcommand to create a new environment variable. For example, to create a variable namedMY_VARIABLEwith the value "Hello from my variable", you would run:export MY_VARIABLE="Hello from my variable" -
To verify that the variable has been created, you can use the
echocommand:echo $MY_VARIABLE -
If you want to make the variable available in child processes, you can simply use it as shown above. If you want to remove the variable later, you can use the
unsetcommand:unset MY_VARIABLE
This will create and manage your environment variable in the current shell session.
