0
0
Linux CLIscripting~10 mins

pwd (print working directory) in Linux CLI - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to print the current directory path.

Linux CLI
[1]
Drag options to blanks, or click blank then click option'
Als
Bmkdir
Ccd
Dpwd
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.
2fill in blank
medium

Complete 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'
A$HOME
B$PWD
C$PATH
D$USER
Attempts:
3 left
💡 Hint
Common Mistakes
Using $HOME which is your home directory, not necessarily current.
Using $PATH which lists executable search paths.
3fill in blank
hard

Fix 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'
A`pwd`
BPWD
Cpwd()
Dpwd
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.
4fill in blank
hard

Fill 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'
A`pwd`
B$current_dir
Cpwd
D$PWD
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.
5fill in blank
hard

Fill 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'
A`pwd`
Bpwd
C$original_dir
Decho
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.