Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to print the current directory path.
Linux CLI
[1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'ls' which lists files instead of showing the current directory.
Using 'cd' which changes directory but does not print it.
✗ Incorrect
The command
pwd prints the current working directory path.2fill in blank
mediumComplete the command to print the current directory path in the terminal.
Linux CLI
echo [1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using $HOME which is your home directory, not necessarily current.
Using $PATH which lists executable search paths.
✗ Incorrect
The environment variable
$PWD holds the current working directory path.3fill in blank
hardFix the error in the command to show the current directory path.
Linux CLI
echo [1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using D 'pwd' prints the literal string 'pwd' instead of executing it.
Using 'pwd()' which is not valid shell syntax.
✗ Incorrect
Using backticks
`pwd` runs the command and prints its output in the shell.4fill in blank
hardFill both blanks to create a command that stores the current directory path in a variable and then prints it.
Linux CLI
current_dir=[1] echo [2]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Assigning the command name without backticks, which stores the string not output.
Printing the variable name without $ which prints the literal text.
✗ Incorrect
Use backticks to assign the output of
pwd to a variable, then print the variable with a $ sign.5fill in blank
hardFill all three blanks to create a script that changes directory, prints the new directory path, and then returns to the original directory.
Linux CLI
original_dir=[1] cd /tmp echo [2] cd [3]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Not storing the original directory before changing.
Using 'pwd' without backticks to print the new directory.
Using variable name without $ when returning.
✗ Incorrect
Store the original directory with backticks, print the current directory with
echo `pwd`, then return using the variable with $.