0
0
Linux CLIscripting~10 mins

Environment variables in Linux CLI - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to display the value of the HOME environment variable.

Linux CLI
echo $[1]
Drag options to blanks, or click blank then click option'
AHOME
BPATH
CUSER
DSHELL
Attempts:
3 left
💡 Hint
Common Mistakes
Using variable names like PATH or USER instead of HOME.
Forgetting the dollar sign ($) before the variable name.
2fill in blank
medium

Complete the code to set a new environment variable named MY_VAR with the value 'hello'.

Linux CLI
export [1]='hello'
Drag options to blanks, or click blank then click option'
AMY_VAR
BVAR
CHELLO
DMYVAR
Attempts:
3 left
💡 Hint
Common Mistakes
Not using export so the variable is not available to other programs.
Using lowercase or incorrect variable names.
3fill in blank
hard

Fix the error in the code to append ':~/bin' to the PATH environment variable.

Linux CLI
export PATH=$PATH:[1]
Drag options to blanks, or click blank then click option'
A$PATH
B~/bin
CPATH
D$PATH:
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'PATH' without the dollar sign, which treats it as a string.
Placing the colon in the wrong place.
Not using the tilde (~) for the home directory.
4fill in blank
hard

Fill both blanks to create a variable named COUNT with value 5 and print it.

Linux CLI
export [1]=[2]
echo $COUNT
Drag options to blanks, or click blank then click option'
ACOUNT
B5
C10
DVALUE
Attempts:
3 left
💡 Hint
Common Mistakes
Putting spaces around the equals sign.
Using the wrong variable name or value.
5fill in blank
hard

Fill all three blanks to create a variable named USERNAME with the current user and print a greeting.

Linux CLI
export [1]=$(whoami)
echo "Hello, $[2]! Your shell is $[3]."
Drag options to blanks, or click blank then click option'
AUSERNAME
CSHELL
DUSER
Attempts:
3 left
💡 Hint
Common Mistakes
Using different variable names in export and echo.
Forgetting to use command substitution with $(whoami).
Using USER instead of SHELL for the shell variable.