0
0
Linux CLIscripting~20 mins

Environment variables in Linux CLI - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Environment Variable Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
1:00remaining
What is the output of this command?
You run this command in a Linux shell:

echo $HOME

What will it output?
Linux CLI
echo $HOME
AThe string "$HOME" literally
BThe path to the current user's home directory, e.g., /home/username
CAn empty line
DThe current working directory path
Attempts:
2 left
💡 Hint
Environment variables start with $ and store system info.
💻 Command Output
intermediate
1:00remaining
What does this command output?
Given you run these commands in order:

export MYVAR=hello
echo $MYVAR

What will the second command output?
Linux CLI
export MYVAR=hello
echo $MYVAR
Aexport MYVAR=hello
B$MYVAR
CAn empty line
Dhello
Attempts:
2 left
💡 Hint
export makes the variable available to child processes.
📝 Syntax
advanced
1: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?
Aexport PATH_EXT=/usr/local/bin
BPATH_EXT=/usr/local/bin
Cset PATH_EXT=/usr/local/bin
Denv PATH_EXT=/usr/local/bin
Attempts:
2 left
💡 Hint
Use export to make variable available in the current shell.
💻 Command Output
advanced
1:00remaining
What error does this command produce?
You run this command:

echo $UNDEFINED_VAR

Assuming UNDEFINED_VAR was never set, what is the output?
Linux CLI
echo $UNDEFINED_VAR
AAn empty line
BUNDEFINED_VAR
Cbash: UNDEFINED_VAR: command not found
D$UNDEFINED_VAR
Attempts:
2 left
💡 Hint
Undefined variables expand to empty strings in bash.
🚀 Application
expert
1:30remaining
How many environment variables are listed by this command?
You run this command in a Linux shell:

env | wc -l

What does the output number represent?
Linux CLI
env | wc -l
AThe number of shell functions defined
BThe number of files in the current directory
CThe number of environment variables currently set
DThe number of running processes
Attempts:
2 left
💡 Hint
env lists environment variables, wc -l counts lines.