0
0
Linux CLIscripting~20 mins

export command in Linux CLI - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Export Command Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
What is the output of the export command?
You run the following commands in a Linux shell:
MYVAR=hello
export MYVAR
export
What will be part of the output when you run export?
Linux CLI
MYVAR=hello
export MYVAR
export
AOnly the variable MYVAR=hello is shown
BA list of all exported environment variables including MYVAR=hello
CNo output is shown
DAn error message saying 'export: command not found'
Attempts:
2 left
💡 Hint
The export command without arguments lists all exported variables.
💻 Command Output
intermediate
2:00remaining
What happens when you export a variable with spaces?
Consider the commands:
export MYVAR=hello world
export MYVAR
What will happen when you run these commands in a Linux shell?
Linux CLI
export MYVAR=hello world
export MYVAR
AMYVAR is unset
BMYVAR is set to 'hello world' correctly
CMYVAR is set to 'hello' and 'world' is treated as a separate command
DSyntax error because of the space in the value without quotes
Attempts:
2 left
💡 Hint
Spaces in variable values need quotes.
🔧 Debug
advanced
2:00remaining
Why does this export command not set the variable in the parent shell?
You run this command in your shell:
export MYVAR=hello
Then in a new terminal, you run:
echo $MYVAR
But it prints nothing. Why?
Linux CLI
export MYVAR=hello
# In a new terminal:
echo $MYVAR
ABecause echo command is wrong
BBecause MYVAR was not set correctly
CBecause export only affects the current shell and its child processes, not new terminals
DBecause export clears variables after the command finishes
Attempts:
2 left
💡 Hint
Think about how environment variables are inherited.
🧠 Conceptual
advanced
2:00remaining
What is the effect of 'export -n VAR' in Linux shell?
You have a variable VAR exported. What does the command export -n VAR do?
Linux CLI
export VAR=hello
export -n VAR
AIt removes the export attribute, so VAR is no longer exported to child processes
BIt sets VAR to an empty string
CIt exports VAR with a new value '-n VAR'
DIt causes a syntax error
Attempts:
2 left
💡 Hint
The -n option removes export status.
🚀 Application
expert
2:00remaining
How to export multiple variables in one command correctly?
You want to export two variables VAR1 and VAR2 with values 'foo' and 'bar' in one command. Which command does this correctly?
Aexport VAR1=foo VAR2=bar
Bexport VAR1=foo; export VAR2=bar
Cexport VAR1=foo, VAR2=bar
Dexport VAR1=foo && VAR2=bar
Attempts:
2 left
💡 Hint
Multiple variables can be exported in one export command separated by spaces.