Recall & Review
beginner
What does the tilde (~) symbol represent in bash scripting?
The tilde (~) represents the current user's home directory path. For example, ~ expands to /home/username.
Click to reveal answer
beginner
How does bash handle the tilde (~) when used at the start of a path?
Bash replaces the tilde (~) at the start of a path with the full path of the user's home directory before running the command.
Click to reveal answer
intermediate
What happens if you use ~username in bash?
Using ~username expands to the home directory of the specified user, not the current user. For example, ~john expands to /home/john.
Click to reveal answer
intermediate
Does tilde expansion happen if ~ is used in the middle of a path, like /tmp/~/file?
No, tilde expansion only happens if ~ is at the start of the path or immediately after a colon (:). In /tmp/~/file, ~ is treated as a normal folder name.
Click to reveal answer
intermediate
Can tilde expansion be used inside quotes in bash?
Tilde expansion does NOT happen inside single quotes ('~'), and it does NOT happen inside double quotes ("~").
Click to reveal answer
What does the command
cd ~ do in bash?✗ Incorrect
The tilde (~) expands to the current user's home directory, so
cd ~ moves you there.What will
echo ~john output if user 'john' exists?✗ Incorrect
Using ~username expands to that user's home directory if the user exists.
Which of these paths will NOT trigger tilde expansion?
✗ Incorrect
Tilde expansion only happens at the start of a path or after a colon (:). In /tmp/~/file, ~ is in the middle and treated literally.
Does tilde expansion occur inside single quotes in bash?
✗ Incorrect
Tilde expansion does not happen inside single quotes because single quotes prevent all expansions.
What does the command
ls ~ do?✗ Incorrect
~ expands to the user's home directory, so ls ~ lists files there.Explain what tilde expansion (~) is and how it helps when working with file paths in bash.
Think about how ~ saves you from typing full home directory paths.
You got /4 concepts.
Describe when tilde expansion does NOT happen in bash and why that matters.
Consider how quoting and position affect tilde behavior.
You got /4 concepts.