Print Working Directory (pwd)
The pwd command shows you where you are in the filesystem. It's one of the simplest but most important commands to know.
What is pwd?
pwd stands for Print Working Directory. It displays the full absolute path of your current location in the filesystem.
Basic Usage
When to Use pwd
Use pwd when you:
- Need to know your exact location
- Want to copy the path for use elsewhere
- Are confused about where you are
- Want to verify you're in the right directory before running commands
pwd Options
| Option | Description |
|---|---|
-L | Print logical path (follows symlinks) - default |
-P | Print physical path (resolves symlinks) |
Most of the time, you'll just use pwd without options.
Working Directory Concept
The working directory is your current location in the filesystem:
- Every terminal session has a working directory
- Commands operate relative to this directory
- When you
cdsomewhere, you change the working directory
Exercise: Print Your Location
Use pwd to find out where you are:
pwd in Scripts
In shell scripts, pwd is often used to:
- Store the current directory for later
- Build paths dynamically
- Verify script location
# Store current directory
CURRENT_DIR=$(pwd)
# Do something elsewhere
cd /tmp
# Return to original location
cd $CURRENT_DIR
Quick Reference
| Command | Result |
|---|---|
pwd | Shows current directory |
pwd -L | Shows logical path |
pwd -P | Shows physical path |
Key Takeaways
pwdshows your current location in the filesystem- It displays the full absolute path
- Essential for knowing where you are before running commands
- Use it often, especially when navigating complex directory structures

