Challenge - 5 Problems
Tilde 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 command?
Consider the command
echo ~ executed by user alice. What will it output?Linux CLI
echo ~
Attempts:
2 left
💡 Hint
The tilde (~) expands to the current user's home directory.
✗ Incorrect
The tilde (~) is a shortcut that the shell expands to the current user's home directory path. For user alice, this is typically /home/alice.
💻 Command Output
intermediate2:00remaining
What does this command output?
What is the output of
echo ~root when run by a normal user?Linux CLI
echo ~root
Attempts:
2 left
💡 Hint
The shell expands ~username to that user's home directory if it exists.
✗ Incorrect
The shell expands ~root to the home directory of the root user, which is usually /root.
📝 Syntax
advanced2:00remaining
Which command correctly changes directory to the home directory of user 'bob'?
You want to change directory to user
bob's home using a shortcut. Which command is correct?Attempts:
2 left
💡 Hint
The tilde followed immediately by username expands to that user's home directory.
✗ Incorrect
cd ~bob changes directory to bob's home directory. Options A and B are incorrect because ~/bob means 'bob' folder inside current user's home, and ~ /bob is invalid syntax. Option D is valid and equivalent to C; the trailing slash is optional and does not change meaning.
🧠 Conceptual
advanced2:00remaining
What does the shortcut
~+ represent in the shell?In bash and similar shells, what does the shortcut
~+ expand to?Attempts:
2 left
💡 Hint
Think about what the shell variable PWD holds.
✗ Incorrect
The shortcut ~+ expands to the current working directory, same as the shell variable $PWD.
💻 Command Output
expert2:00remaining
What is the output of this command sequence?
Given the commands run in order:
What will be printed?
cd /tmpecho ~-What will be printed?
Linux CLI
cd /tmp echo ~-
Attempts:
2 left
💡 Hint
The shortcut
~- expands to the previous working directory.✗ Incorrect
The shortcut ~- expands to the previous working directory. Assuming the user started in /home/alice and then changed to /tmp, ~- will expand to /home/alice.