Challenge - 5 Problems
Master of cd command
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
What is the output of this sequence of commands?
Assume you start in your home directory
What is the output of
/home/user. You run these commands:cd /var/logcd ../libpwdWhat is the output of
pwd?Linux CLI
cd /var/log cd ../lib pwd
Attempts:
2 left
💡 Hint
Remember that
.. moves one directory up from the current location.✗ Incorrect
Starting at /var/log,
cd ../lib moves up to /var, then into lib, so the path is /var/lib.💻 Command Output
intermediate1:30remaining
What happens when you run
cd -?You start in
/home/user, then run cd /etc. Next, you run cd -. What directory will you be in after the last command?Linux CLI
cd /home/user cd /etc cd - pwd
Attempts:
2 left
💡 Hint
cd - switches to the previous directory you were in.✗ Incorrect
The
cd - command returns you to the last directory you were in, which is /home/user.💻 Command Output
advanced1:00remaining
What error does this command produce?
You run this command:
What error message will the shell show?
cd /nonexistent/pathWhat error message will the shell show?
Linux CLI
cd /nonexistent/path
Attempts:
2 left
💡 Hint
Think about what happens if you try to go to a folder that does not exist.
✗ Incorrect
The shell reports that the directory does not exist with the message: 'No such file or directory'.
💻 Command Output
advanced1:30remaining
What is the output of this command sequence involving symbolic links?
Assume
What is the output?
/tmp/link is a symbolic link to /var/log. You run:cd /tmp/linkpwd -PWhat is the output?
Linux CLI
cd /tmp/link pwd -P
Attempts:
2 left
💡 Hint
The
-P option shows the physical directory, resolving symbolic links.✗ Incorrect
Using
pwd -P shows the real directory path, so it outputs /var/log.🚀 Application
expert2:30remaining
How many directories deep is the final location?
Starting at
How many directories deep is the final directory from the root
/home/user, you run:cd ../../etc/../var/./log/../libHow many directories deep is the final directory from the root
/? (Count each directory level in the path)Linux CLI
cd ../../etc/../var/./log/../lib pwd
Attempts:
2 left
💡 Hint
Simplify the path step by step, removing
. and resolving ...✗ Incorrect
The final path is /var/lib which has 2 directory levels: var, lib.