In UNIX, which command correctly displays the present working directory (the full path of the current directory)?

Difficulty: Easy

Correct Answer: $pwd

Explanation:


Introduction / Context:
On UNIX and Linux systems, users often need to know exactly which directory they are currently working in, especially when navigating complex directory trees. The command line provides specific utilities to show the present working directory. Recognizing the correct command and its purpose is basic but essential knowledge for anyone using a shell.



Given Data / Assumptions:

  • The question is about UNIX command line usage.
  • The term present working directory refers to the full path of the directory where the shell is currently located.
  • Several example commands are provided, including who, pwd, and a phrase that is not a valid command.
  • The task is to select the command that displays the current directory path.


Concept / Approach:
The standard UNIX command to display the present working directory is pwd, which stands for "print working directory". When typed at the shell prompt, pwd outputs the absolute path of the current directory. The who command, by contrast, displays information about logged in users, while a phrase like "who are you" is not a valid single command. Therefore, among the choices, pwd is the correct command for showing the present working directory.



Step-by-Step Solution:
Step 1: Recall that the shell maintains a current directory and that commands such as cd change this directory.Step 2: Identify pwd as the command that prints the full path of the current working directory.Step 3: Recognize that who is a different command used for listing users currently logged into the system.Step 4: Notice that the phrase "who are you" is not a single UNIX command; the shell will interpret it as a command name with arguments and will not treat it as a built in directory utility.Step 5: Conclude that the correct answer is the command pwd, written at the prompt as $pwd.


Verification / Alternative check:
On a UNIX or Linux system, you can type pwd in a terminal to see the path, such as /home/user/projects. The manual page for pwd confirms that it prints the name of the current or present working directory. In contrast, running who shows a list of users and terminals, which is unrelated to directory paths. This practical behavior and documentation verify that pwd is the correct command.



Why Other Options Are Wrong:
Option A, $who, is incorrect because it runs the who command, which lists logged in users and terminals, not directories. Option C, $who are you, is not a single valid command to display paths; "who" is treated as a command with extra arguments and still does not show the current directory. Option D is wrong because there is a correct command in the list, namely $pwd, so it is not true that none of them display the path.



Common Pitfalls:
Beginners sometimes confuse commands because their names are short and similar. They may also rely on graphical file managers and forget the text based commands for navigation. Another pitfall is to assume that the shell prompt itself always shows the full path; while many prompts do this, the authoritative way to check is by using pwd. Remembering that pwd stands for "print working directory" helps keep this command clear.



Final Answer:
The UNIX command that displays the present working directory is pwd, typed as $pwd at the shell prompt.


Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion