Challenge - 5 Problems
PATH Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
What is the output of this PATH modification?
Consider the following commands run in a Linux shell:
What will be the first directory in the PATH variable after running this command if the original PATH was
export PATH=/usr/local/bin:$PATHWhat will be the first directory in the PATH variable after running this command if the original PATH was
/usr/bin:/bin?Linux CLI
export PATH=/usr/local/bin:$PATH echo $PATH
Attempts:
2 left
💡 Hint
Remember that placing a directory before $PATH adds it to the front.
✗ Incorrect
The command prepends /usr/local/bin to the existing PATH, so it becomes the first directory.
💻 Command Output
intermediate2:00remaining
What happens if you append an empty directory to PATH?
Given the command:
What is the effect of the double colon (::) in the PATH variable?
export PATH=$PATH::/usr/binWhat is the effect of the double colon (::) in the PATH variable?
Linux CLI
export PATH=$PATH::/usr/bin echo $PATH
Attempts:
2 left
💡 Hint
Empty entries in PATH are interpreted as the current directory.
✗ Incorrect
In PATH, an empty entry between colons means the current directory (.) is included at that position.
📝 Syntax
advanced2:00remaining
Which command correctly removes /usr/local/bin from PATH?
You want to remove /usr/local/bin from the PATH variable in a bash shell. Which of the following commands will do this correctly?
Attempts:
2 left
💡 Hint
Consider the position of /usr/local/bin in PATH and the colon separators.
✗ Incorrect
Option D removes /usr/local/bin only if it is at the start followed by a colon, avoiding partial matches elsewhere.
💻 Command Output
advanced2:00remaining
What is the output of this PATH check script?
Given this bash script snippet:
What will be printed if PATH is
if [[ ":$PATH:" == *":/opt/bin:"* ]]; then echo "Found" else echo "Not Found" fi
What will be printed if PATH is
/usr/bin:/opt/bin:/bin?Linux CLI
PATH=/usr/bin:/opt/bin:/bin if [[ ":$PATH:" == *":/opt/bin:"* ]]; then echo "Found" else echo "Not Found" fi
Attempts:
2 left
💡 Hint
The script adds colons around PATH to avoid partial matches.
✗ Incorrect
The pattern matches :/opt/bin: inside :$PATH:, so it prints Found.
🚀 Application
expert3:00remaining
How to permanently add a directory to PATH for all users?
You want to add
/custom/tools to the PATH environment variable permanently for all users on a Linux system. Which file is the best place to add this export command to achieve this?Attempts:
2 left
💡 Hint
Think about system-wide environment variables for all users.
✗ Incorrect
/etc/profile is executed for login shells for all users, making it the best place for system-wide PATH changes.