What is pwd
?
The pwd
command stands for “Print Working Directory”. It shows the full path to your current directory — i.e., where you are located in the filesystem.
Syntax
The command is simple and usually run without options.
Basic Usage
Output Example:
This tells you that you're currently inside the Documents
directory of the user username
.
Why Use pwd
?
-
To know your current location in the terminal
-
Helps with navigating complex directory structures
-
Useful in scripts for debugging paths
Step-by-Step Examples
Step 1: Open Terminal
Start your terminal on any Linux distribution.
Step 2: Run pwd
Shows the current full directory path.
Step 3: Change Directory & Use pwd
Output:
Now you know you are inside the /etc
directory.
Step 4: Use with Other Commands
You can combine pwd
with other commands in scripts:
Options with pwd
The most common usage is without options, but you may come across:
Option | Description |
---|---|
-L | (Logical) Shows the logical path (default) |
-P | (Physical) Resolves symlinks to show real path |
Example:
Real Use Cases
-
Find your location in a nested folder:
-
Add path to logs or scripts:
Summary
Command | Description |
---|---|
pwd | Shows current working directory |
pwd -P | Shows physical path (resolves links) |
pwd -L | Shows logical path (default) |
Let me know if you'd like this as a printable cheat sheet or if you need a practice exercise using pwd
, cd
, and ls
together!