What is the difference between -L and -P?

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:

  1. -L (Logical Path):

    • Displays the logical path of the current directory.
    • If you are in a directory that is a symbolic link, pwd -L will show the path as it appears in the file system, including the symbolic link.
    • This is the default behavior of pwd if no options are specified.

    Example:
    If you are in a directory /home/user/docs where docs is a symbolic link to /mnt/storage/docs, running:

    pwd -L

    will output:

    /home/user/docs
  2. -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 -P

    will 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.

0 Comments

no data
Be the first to share your comment!