Menu
Coddy logo textTech

Environment Variables

Part of the Fundamentals section of Coddy's Terminal journey — lesson 59 of 82.

Environment variables are named values stored in your shell's memory that programs and commands can access. Think of them as settings that shape how your terminal session behaves.

Every time you open a terminal, the system automatically sets up several environment variables. These store useful information like your username, home directory path, and preferred text editor. Programs read these variables to understand the context they're running in.

To view the value of a specific environment variable, use the echo command with a $ prefix before the variable name:

echo $HOME

This displays your home directory path. The $ tells the shell to substitute the variable's value. Here are a few common environment variables:

VariableContains
HOMEYour home directory path
USERYour username
SHELLYour current shell program
PWDPresent working directory

Without the $, echo would just print the literal text "HOME" instead of the variable's value. This distinction between the variable name and its value is important to remember as you work with environment variables.

challenge icon

Challenge

Easy

Use the echo command to display the value of the SHELL environment variable.

Remember to use the $ prefix before the variable name to access its value. Without the $, you would just print the literal text "SHELL" instead of the actual shell path.

Your output should display the path to your current shell program (something like /bin/bash).

Hint: The command format is echo $VARIABLE_NAME

Cheat sheet

Environment variables are named values stored in your shell's memory that programs and commands can access.

To view the value of an environment variable, use echo with a $ prefix:

echo $HOME

The $ tells the shell to substitute the variable's value. Without it, echo prints the literal text instead.

Common environment variables:

VariableContains
HOMEYour home directory path
USERYour username
SHELLYour current shell program
PWDPresent working directory

Try it yourself

Terminal
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Fundamentals