Difficulty: Easy
Correct Answer: pwd
Explanation:
Introduction / Context:
Navigating the filesystem efficiently requires awareness of your current directory. The pwd utility echoes the absolute path to the directory the shell considers current, which is critical when scripting, troubleshooting permissions, or composing relative paths.
Given Data / Assumptions:
Concept / Approach:
pwd expands any symbolic links based on implementation or options (for example, pwd -P for the physical directory). It reads from the shell’s notion of the current directory, which updates when cd is executed. This information is often embedded into shell prompts as well.
Step-by-Step Solution:
Verification / Alternative check:
Cross-check with ls to list directory contents, confirming you are where you expect. Use realpath . for an explicit physical path.
Why Other Options Are Wrong:
a: path is a DOS command for executable search path; not a UNIX directory query.
c: prompt $p$g is a DOS prompt customization, irrelevant in UNIX.
d: dir lists directory contents (DOS/also an alias to ls on some systems) but does not print the current path like pwd.
e: Not applicable because pwd is correct.
Common Pitfalls:
Confusing logical vs physical paths when symlinks are involved; using cd -P and pwd -P to avoid ambiguity in scripts that rely on actual filesystem paths.
Final Answer:
pwd
Discussion & Comments