LOGBOOK

HELP

Quiz Entry - updated: 2026.07.14

What are the most important environment variables in Linux?

*The shell pre-populates variables describing your session — $HOME`, `$USER, $PATH`, `$PWD — plus special ones like $?` (last exit code) and `%%MATH_BLOCK_0%%`, `$!) are set by bash itself and report runtime state; $? in particular is the workhorse for checking whether the previous command succeeded.

Variable Description Example
$HOME User's home directory /home/student
$USER Current username student
$HOSTNAME System hostname server01
$SHELL Default shell /bin/bash
$PATH Command search path /usr/bin:/bin
$PWD Current directory /home/student
$LOGNAME Login name student
$? Last command exit code 0
$$ Current shell PID 12345
$! Last background PID 12346

View all environment variables:

env          # All exported variables
set          # All variables (including local)
echo $PATH   # Specific variable

Export to child processes:

export MY_VAR="value"

From Quiz: LIOS / Bash Scripting and Automation | Updated: Jul 14, 2026