Managing Environment Variables
Concept & Overview
Imagine you are deploying a web application, and it needs to know whether to run in a safe local "development" sandbox or connect to the live "production" database. In Linux, we pass configurations like this to running programs using environment variables.
- We use the export command to define a variable so that any programs started by our shell can read it. E.g., export APP_ENV=production.
- To check or display a variable's value, we prefix its name with a dollar sign: echo $APP_ENV.
APP_ENV with the value production by running export APP_ENV=production, and then verify it by running echo $APP_ENV.Command Syntax Reference
| Command / Syntax | Description |
|---|---|
export VAR=val | Define environment variable |
echo $VAR | Print variable value |
Verification Objectives
These conditions will be automatically verified when you run commands inside the interactive terminal simulator:
- ○Run the "export" command
- ○Set APP_ENV env variable to "production"
- ○Print variable using "echo $APP_ENV"
Ready to complete Quest 115?
Test your skills live in the browser terminal with an emulated Linux filesystem, real-time command evaluation, and instant step-by-step hints.