Bash pwd
- Print Working Directory
Using the pwd
Command
The pwd
command shows you the full path of the folder you're currently in.
Basic Usage
To see the full path of the current folder, just type pwd
:
Example
pwd
/home/user/my_directory
Options Overview
The pwd
command supports a few options to customize its output:
-L
: Display the logical current working directory-P
: Display the physical current working directory (without symbolic links)
-L
Option: Logical Path
The -L
option shows the logical path, including any symbolic links.
This is the default behavior of pwd
.
Example: Logical Path
pwd -L
/home/user/my_directory
-P
Option: Physical Path
The -P
option shows the physical path, resolving any symbolic links to their actual locations.
This is useful when you need to know the exact physical directory structure.
Example: Physical Path
pwd -P
Why Knowing Your Current Directory is Important
Knowing which folder you're in is important when moving around the filesystem. It helps you make sure you're in the right place when running commands that use relative paths.
Common Use Cases for pwd
- Running Scripts: Make sure your script is using the right files and folders.
- Managing Files: Check where you are before copying or moving files to avoid mistakes.
- Fixing Problems: Knowing your current folder can help you solve path-related issues.