How to Use pwd Command in Linux
Learn to use the 'pwd' command in Linux for efficient directory tracking and navigation.
The pwd
command, standing for ‘print working directory’, is one of the most commonly used commands in the Linux operating system. This command is used to display the absolute path of the current directory you’re working in. The absolute path means the complete path starting from the root directory, /
, to the current directory you are in.
When you open your terminal, you usually start in your home directory. But as you navigate through other directories using the cd
(change directory) command, you might lose track of where you currently are. That’s when pwd
comes handy. By typing pwd
and pressing enter, the terminal will output the full directory path where you’re currently located.
Here are some ways to use the pwd
command:
1. Print Working Directory
The basic usage of pwd
without any options will display the full path of the current directory.
pwd
This will output something like /home/username/directory
, depending on your current directory.
2. Print Physical Directory
If you have navigated through a symbolic link to a directory, pwd
will show the logical path that includes the symbolic link. If you want to see the actual physical path, you can use the -P
option.
pwd -P
3. Print Logical Directory
Conversely, if you want to ensure that pwd
shows the logical path including symbolic links, you can use the -L
option. However, this is usually the default behavior.
pwd -L
More Linux commands:
Directory Operations | rmdir · cd · pwd · exa · ls |
File Operations | cat · cp · dd · less · touch · ln · rename · more · head |
File System Operations | chown · mkfs · locate |
Networking | ping · curl · wget · iptables · mtr |
Search and Text Processing | find · grep · sed · whatis · ripgrep · fd · tldr |
System Information and Management | env · history · top · who · htop · glances · lsof |
User and Session Management | screen · su · sudo · open |