0
0
Linux CLIscripting~20 mins

pwd (print working directory) in Linux CLI - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Pwd Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
1:00remaining
What is the output of the pwd command?
You run the pwd command in your terminal. What does it show?
Linux CLI
pwd
A/home/username
Busername@hostname:~$
Cls -l
DNo such file or directory
Attempts:
2 left
💡 Hint
Think about what 'pwd' stands for and what it shows you in your terminal.
💻 Command Output
intermediate
1:30remaining
What happens if you run pwd after changing directories?
You run these commands in order:
cd /var/log
pwd
What is the output of the second command?
Linux CLI
cd /var/log
pwd
A/var/log
B/home/username
Ccd: /var/log: No such file or directory
D/var
Attempts:
2 left
💡 Hint
The cd command changes your directory, and pwd shows where you are now.
📝 Syntax
advanced
1:00remaining
Which command correctly prints the current directory?
Choose the correct command that prints the current working directory.
Aprint working directory
Bpwd()
Cpwd
Dshow pwd
Attempts:
2 left
💡 Hint
The command is a simple shell command without parentheses or extra words.
🔧 Debug
advanced
1:30remaining
What error occurs if you run pwd in a deleted directory?
You are inside a directory, then from another terminal, that directory is deleted. Now you run pwd. What happens?
Linux CLI
pwd
ACommand not found
B/home/username
CPermission denied
Dpwd: error retrieving current directory: No such file or directory
Attempts:
2 left
💡 Hint
Think about what happens if your current directory no longer exists.
🚀 Application
expert
2:00remaining
How to use pwd output in a script to create a backup folder?
You want to create a backup folder named 'backup' inside your current directory using a shell script. Which command correctly uses pwd output to do this?
Amkdir pwd/backup
Bmkdir "$(pwd)/backup"
Cmkdir $pwd/backup
Dmkdir `pwd/backup`
Attempts:
2 left
💡 Hint
Use command substitution syntax to get the output of pwd.