Environment Variables
In this page:
Environment Variables
Environment variables like $HOME, $USER, and $PATH are set by the system or shell and are available to every script and program that runs. They carry configuration and context, such as the current user's home directory. You can read them just like any other variable, with $.
Note: Run env or printenv in a terminal to see all environment variables currently set.
Example: Environment Variables
#!/bin/bash
echo "Home directory: $HOME"
echo "Current user: $USER"
echo "Shell: $SHELL"
Login to try C/C++/Java/PHP code in the editor
🔒
Chapter Quiz — Complete all 13 topics to unlock
0/13 topics done
Complete these topics first: