0
0
Linux-cliHow-ToBeginner · 3 min read

How to Print Working Directory in Linux: Simple Command Guide

To print the current working directory in Linux, use the pwd command. This command shows the full path of the directory you are currently in.
📐

Syntax

The basic syntax to print the working directory is simple:

  • pwd: Prints the full path of the current directory.
bash
pwd
Output
/home/username
💻

Example

This example shows how to use pwd to display your current directory path in the terminal.

bash
pwd
Output
/home/username
⚠️

Common Pitfalls

Some common mistakes when trying to print the working directory include:

  • Typing pwd with typos like pwwd or pwdw, which will cause a command not found error.
  • Expecting pwd to change the directory; it only prints the current directory.
  • Running pwd inside scripts without understanding the script's current directory context.
bash
pwwd
# Wrong command, will cause error

pwd
# Correct command to print working directory
Output
bash: pwwd: command not found /home/username
📊

Quick Reference

Use this quick reference to remember the pwd command:

CommandDescription
pwdPrints the full path of the current working directory
cdChanges the current directory (not for printing)
lsLists files in the current directory

Key Takeaways

Use the pwd command to print your current directory path in Linux.
pwd only shows the directory; it does not change it.
Avoid typos in the command to prevent errors.
Remember pwd is useful in scripts to know the current directory context.