Progress: 0/62 (0%)
🌍 Environment Variables
Environment Variables
Think of environment variables as little sticky notes for your terminal. They tell programs "Hey, here's some info you might need" — like where to find commands, what language to use, or where to store temp files.
Think of environment variables as little sticky notes for your terminal. They tell programs "Hey, here's some info you might need" — like where to find commands, what language to use, or where to store temp files.
What They Are
Environment variables are stored in your shell session and are available to programs started from that session. Common examples include:
- HOME → your home directory
- USER → your username
- PATH → where the system looks for commands
How to Set Them (export)
Example:
export MY_VAR="HelloWorld"
This creates a variable called MY_VAR that programs can see.
echo $MY_VAR
Use this command to check the value of the variable.
PATH Variable
The PATH variable is special: it tells the shell where to look for commands.
echo $PATH
📌 Example:
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
If you install a program in /opt/myprogram/bin, add it to PATH:
export PATH=$PATH:/opt/myprogram/bin
Now, you can run the program from anywhere.
Real-life analogy
Imagine your PATH is like a city map. When you tell a friend to meet you somewhere, they need the streets (folders) to find you. If the street isn't on the map, your friend gets lost (command not found).