0
0
Linux CLIscripting~10 mins

PATH variable management 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 current PATH variable.

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

Complete the code to add the directory /usr/local/bin to the PATH variable temporarily.

Linux CLI
export PATH=[1]:/usr/local/bin
Drag options to blanks, or click blank then click option'
A/usr/bin
B$PATH
C$HOME
DPATH
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting the $ sign before PATH.
Replacing PATH instead of appending to it.
3fill in blank
hard

Fix the error in the code that tries to add /opt/bin to PATH but overwrites it.

Linux CLI
export PATH=[1]:/opt/bin
Drag options to blanks, or click blank then click option'
A$HOME
BPATH
C$PATH
D/opt/bin
Attempts:
3 left
💡 Hint
Common Mistakes
Writing PATH without $ causing the variable to be overwritten.
Using unrelated variables like $HOME.
4fill in blank
hard

Fill both blanks to permanently add /custom/bin to PATH in the .bashrc file.

Linux CLI
echo 'export PATH=[1]:[2]' >> ~/.bashrc
Drag options to blanks, or click blank then click option'
A$PATH
B/custom/bin
C$HOME
D/usr/local/bin
Attempts:
3 left
💡 Hint
Common Mistakes
Overwriting PATH by not including $PATH.
Adding wrong directory paths.
5fill in blank
hard

Fill all three blanks to create a script that adds /my/bin to PATH only if it's not already included.

Linux CLI
if [[ ":$[1]:" != *":[2]:"* ]]; then
  export PATH=[3]:/my/bin
fi
Drag options to blanks, or click blank then click option'
APATH
B/my/bin
C$PATH
D/usr/bin
Attempts:
3 left
💡 Hint
Common Mistakes
Not using colons around PATH for accurate matching.
Using PATH without $ to get its value.
Appending instead of prepending PATH.