Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to print the current user's home directory using tilde expansion.
Bash Scripting
echo [1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using $PWD instead of ~, which gives the current directory, not home.
Using $HOME works but is not tilde expansion.
✗ Incorrect
The tilde (~) expands to the current user's home directory in bash.
2fill in blank
mediumComplete the command to list files in the home directory of user 'alice' using tilde expansion.
Bash Scripting
ls [1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Adding a slash between ~ and username breaks tilde expansion.
Using ~/alice looks for a directory named 'alice' inside your home.
✗ Incorrect
Using ~alice expands to the home directory of user 'alice'.
3fill in blank
hardFix the error in the command to copy a file to the home directory using tilde expansion.
Bash Scripting
cp file.txt [1]/documents/ Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Quoting ~ disables tilde expansion.
Using $HOME works but is not tilde expansion.
✗ Incorrect
Tilde expansion works only when ~ is unquoted. Quoting disables expansion.
4fill in blank
hardFill both blanks to create a directory path inside the current user's home directory.
Bash Scripting
mkdir [1]/[2]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using /home instead of ~ for home directory.
Using 'documents' instead of 'projects' if the task expects 'projects'.
✗ Incorrect
Use ~ for home directory and 'projects' as the folder name.
5fill in blank
hardFill all three blanks to create a file path to 'notes.txt' inside user 'bob's Documents folder using tilde expansion.
Bash Scripting
cp notes.txt [1]/[2]/[3]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using ~bob/Downloads instead of Documents.
Putting quotes around ~bob disables expansion.
✗ Incorrect
Use ~bob for bob's home, 'Documents' folder, and 'notes.txt' file.