pwd CommandpwdThe pwd (print working directory) command in Linux is used to display the full path of the current directory you are working in. Here's how to use it:
pwd
This will return the absolute path of your current directory. For example:
/home/user/Documents
pwdThe pwd command has two main options that control how it displays the path:
pwd -L (Logical Path)This option shows the logical path, meaning it displays the path with any symbolic links:
/var/www
Even if /var/www is a symlink to /home/user/public_html, pwd -L will show the path you entered.
pwd -P (Physical Path)This option resolves and displays the actual physical path by ignoring symbolic links:
/home/user/public_html
-L and -P| Option | Description |
|---|---|
pwd -L |
Shows the logical path (includes symbolic links). |
pwd -P |
Shows the actual physical path (ignores symbolic links). |
pwd to display the current directory.pwd in scripts to ensure you're in the correct directory.pwd -P to verify the actual physical location of a directory.For more detailed information, use the man pwd command:
man pwd