pwd command

The pwd command allows the user to view their current location in the directory structure.

Command: pwd
Synopsis: pwd [OPTION]…

These are the few options available for the pwd command.

OptionLong NameDescription
-L–logicaluse PWD from environment, even if it contains symlinks
-P–physicalavoid all symlinks

If both -L and -P are entered (pwd -LP or pwd -PL), the last one will be used. If neither option is used, the -L option will be assumed by default.


Using the base command

Using the pwd command will result in displaying the path where the user is located.

$# pwd /home/userna5/public_html   

Using the logical option

Using the logical option will display the path including symlinks. For the example below we are in a folder named ‘www‘, the www folder is actually a symlink to the public_html folder. The result displays the www folder in the path as if it were an actual folder.

$# pwd -L /home/userna5/www   

Using the physical option

Using the physical option will display the path not including any symlinks. As in the above example, we are in the www folder. However, since it is a symlink to the public_html folder, it displays the actual physical folder it is in instead, which is public_html.

$# pwd -P /home/userna5/public_html   

Was this article helpful? Let us know!