The -L and -P options for the pwd command in Linux specify how the current working directory is displayed, particularly in relation to symbolic links:
-
-L(Logical Path):- Displays the logical path of the current directory.
- If you are in a directory that is a symbolic link,
pwd -Lwill show the path as it appears in the file system, including the symbolic link. - This is the default behavior of
pwdif no options are specified.
Example:
If you are in a directory/home/user/docswheredocsis a symbolic link to/mnt/storage/docs, running:pwd -Lwill output:
/home/user/docs -
-P(Physical Path):- Displays the physical path of the current directory.
- It resolves all symbolic links and shows the actual path in the file system.
- This option is useful when you want to see the real directory structure without any symbolic links.
Example:
Using the same scenario as above, running:pwd -Pwill output:
/mnt/storage/docs
In summary, use -L to see the path as it is logically represented (including symbolic links) and -P to see the actual physical path without symbolic links.
