Challenge - 5 Problems
Environment Variable Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate1:00remaining
What is the output of this command?
You run this command in a Linux shell:
What will it output?
echo $HOMEWhat will it output?
Linux CLI
echo $HOME
Attempts:
2 left
💡 Hint
Environment variables start with $ and store system info.
✗ Incorrect
The $HOME variable holds the path to the current user's home directory. Using echo $HOME prints that path.
💻 Command Output
intermediate1:00remaining
What does this command output?
Given you run these commands in order:
What will the second command output?
export MYVAR=helloecho $MYVARWhat will the second command output?
Linux CLI
export MYVAR=hello echo $MYVAR
Attempts:
2 left
💡 Hint
export makes the variable available to child processes.
✗ Incorrect
After exporting MYVAR with value 'hello', echo $MYVAR prints 'hello'.
📝 Syntax
advanced1:30remaining
Which option correctly sets an environment variable for the current shell session?
You want to set an environment variable named PATH_EXT to "/usr/local/bin" for your current shell session only. Which command is correct?
Attempts:
2 left
💡 Hint
Use export to make variable available in the current shell.
✗ Incorrect
Only 'export PATH_EXT=/usr/local/bin' sets and exports the variable in the current shell session.
💻 Command Output
advanced1:00remaining
What error does this command produce?
You run this command:
Assuming UNDEFINED_VAR was never set, what is the output?
echo $UNDEFINED_VARAssuming UNDEFINED_VAR was never set, what is the output?
Linux CLI
echo $UNDEFINED_VAR
Attempts:
2 left
💡 Hint
Undefined variables expand to empty strings in bash.
✗ Incorrect
If a variable is not set, referencing it with $VAR returns an empty string, so echo prints a blank line.
🚀 Application
expert1:30remaining
How many environment variables are listed by this command?
You run this command in a Linux shell:
What does the output number represent?
env | wc -lWhat does the output number represent?
Linux CLI
env | wc -l
Attempts:
2 left
💡 Hint
env lists environment variables, wc -l counts lines.
✗ Incorrect
The env command lists all environment variables, and wc -l counts how many lines are output, which equals the number of variables.