🐧 Linux / Shell Scripting
Beginner
What are environment variables and how do you use $PATH and $HOME?
Answer
Environment variables are named values that are inherited by child processes and configure program behavior. $HOME holds the current user's home directory (/home/alice). $PATH is a colon-separated list of directories the shell searches for executables when you type a command — if a program isn't in any $PATH directory, the shell reports "command not found." View all variables with env or printenv. Set a variable: export MY_VAR="value" (makes it available to child processes). Add to PATH permanently: add export PATH="$PATH:/new/dir" to ~/.bashrc or ~/.profile. Per-command variables: DEBUG=1 ./myapp sets the variable only for that invocation.