Which command prints the current working directory in a Unix-like shell?

Study for the SANS560 GIAC Penetration Tester (GPEN) Test. Study with flashcards and multiple choice questions, each question has hints and explanations. Get ready for your exam!

Multiple Choice

Which command prints the current working directory in a Unix-like shell?

Explanation:
The command to print the current directory is pwd, which stands for print working directory. It outputs the absolute path from the filesystem root to your current location, so you always know exactly where you are in the hierarchy. In most shells it’s a built-in, though there may also be an external version. Some implementations offer options like -P to show the physical path with symbolic links resolved, or -L to show the path as you navigated it. If you want a quick reference, you can also echo $PWD, but pwd is the standard way to display the current working directory. The other commands perform different tasks: listing contents, changing directories, or creating files, none of which print your current location.

The command to print the current directory is pwd, which stands for print working directory. It outputs the absolute path from the filesystem root to your current location, so you always know exactly where you are in the hierarchy. In most shells it’s a built-in, though there may also be an external version. Some implementations offer options like -P to show the physical path with symbolic links resolved, or -L to show the path as you navigated it. If you want a quick reference, you can also echo $PWD, but pwd is the standard way to display the current working directory. The other commands perform different tasks: listing contents, changing directories, or creating files, none of which print your current location.

Subscribe

Get the latest from Passetra

You can unsubscribe at any time. Read our privacy policy