pwd (Print Working Directory)
The pwd command stands for Print Working Directory. It is used to output the full absolute path of the current directory you are working in. It's essentially the "You Are Here" marker for your terminal session.
1. Basic Usage
pwd
- Executing this will display the absolute path starting from the root (
/), such as/home/user/projects.
2. Key Options
| Option | Name | Description |
|---|---|---|
-L |
Logical | Displays the logical path, including symbolic links. (Default behavior) |
-P |
Physical | Displays the actual physical path, resolving any symbolic links to their source. |
3. Practical Examples
① Getting the Absolute Path for Configuration
When you need to copy the full path of your current workspace into a config file:
pwd
# Output example: /etc/nginx/sites-available
② Finding the Real Source of a Linked Directory
If you are inside a directory that is a symbolic link, use -P to see where the files actually reside:
pwd -P
# Output example: /mnt/external_drive/backup_data
4. [Tip] The $PWD Environment Variable
In addition to the command, the shell maintains an environment variable called PWD. You can also view your current path by printing this variable:
echo $PWD