Junior — Middle
How can an environment variable be set in an operating system?
sobes.tech AI
Answer from AI
Environment variables in operating systems are set differently:
-
In Linux/macOS (bash):
- Temporary variable for the current session:
export VARIABLE_NAME=value - To make the variable available in all new sessions, add it to configuration files such as
~/.bashrcor~/.profile.
- Temporary variable for the current session:
-
In Windows (cmd):
- Temporary variable for the current session:
set VARIABLE_NAME=value - To set a variable permanently via the interface: "Control Panel" → "System" → "Advanced system settings" → "Environment Variables".
- Using PowerShell:
$Env:VARIABLE_NAME = "value"
- Temporary variable for the current session:
Thus, environment variables can be set temporarily for the current session or permanently through configuration files or system settings.