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
pwdwith typos likepwwdorpwdw, which will cause a command not found error. - Expecting
pwdto change the directory; it only prints the current directory. - Running
pwdinside scripts without understanding the script's current directory context.
bash
pwwd
# Wrong command, will cause error
pwd
# Correct command to print working directoryOutput
bash: pwwd: command not found
/home/username
Quick Reference
Use this quick reference to remember the pwd command:
| Command | Description |
|---|---|
| pwd | Prints the full path of the current working directory |
| cd | Changes the current directory (not for printing) |
| ls | Lists 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.