Introduction
Imagine you are moving into a new office. The desk has a specific height, and the nameplate shows your name. In Linux, "Environment Variables" are exactly like these settings. They store information about your session.
Every program you run can look at these variables to understand how to behave.
This is one of the quiet mechanisms that makes a shell session feel personalized. Programs often learn who you are, where your home directory is, which language to use, and how to locate tools by reading variables that the shell passes along.
In this lab, you will learn how to:
- Print the value of a logical variable.
- Identify which shell program you are using.
- List all active settings.
Print User ($USER)
A variable is like a labeled box. The box has a name (USER) and a value (labex).
To see the value, we use echo with a dollar sign $. The $ is the key that unlocks the box.
More precisely, the shell sees $USER and replaces it with the stored value before running the command. This replacement behavior is part of why variables are so useful in shell work.
Type this to see who you are:
echo $USER
Output:
labex
You can combine text with variables:
echo "Hello, $USER"
Output:
Hello, labex
This makes commands flexible. Hello, $USER works for anyone.
Print Shell ($SHELL)
The Shell is the program you are typing into. It interprets your commands.
Different shells speak slightly different "dialects" (Bash, Zsh, etc.).
That is why environment details matter. The shell is not just a blank prompt; it is a program with its own configuration, syntax habits, and startup behavior.
Check which shell you are using:
echo $SHELL
Output:
/usr/bin/zsh
You are using Zsh. On other systems, you might see /bin/bash.
List All Variables (env)
To see the "big picture," use env.
It lists every environment variable set in your session.
This is useful because a shell session is more than the commands you type. It also carries background context that programs inherit automatically.
env
You will see a large block of text:
HOSTNAME=labex-instance
PWD=/home/labex/project
HOME=/home/labex
LANG=en_US.UTF-8
...
Notice useful variables like:
PWD: Current directory.HOME: Your home folder.LANG: Your language setting.
Summary
In this lab, you have taken your first steps into understanding the Linux environment. You have learned:
- Variables are containers: They hold information like your username or preferences.
- The $ key: You use the dollar sign (e.g.,
$USER) to unlock and read the value inside a variable. - The Shell: The interface you use (
/bin/zshor/bin/bash) is defined in the$SHELLvariable. - The Environment: You can see the entire list of system settings using the
envcommand.
These concepts are the foundation of Linux configuration. In later labs, you will learn how to create your own variables and change how the system behaves!



