pwd command in Linux – syntax, options, use and example

pwd stands for Print Working Directory. It prints the complete absolute path of current directory you are in.

While working with Linux files and directories, you move around from one directory to another. Anytime if you want to know in which directory you are in then, pwd command tells you that.

Syntax

pwd [-LP]

Where L and P are optional options.

Options

OptionsDescription
-LDisplays the logical path of current working directory. This logical path includes the symbolic link path of current working directory.

This is the default option, if no options specified.
-PDisplays the physical path of current working directory after resolving symbolic links. It shows the full pathname without symbolic link of the current working directory.

Note: When no option is specified with the command pwd , it automatically considers -L into action.

Examples

Let us try some fun with pwd command and see where we exist.

To know current working directory just hit either pwd or pwd -L in any directory.

pwd command in linux

pwd or pwd -L both are equivalent.

Let us now try pwd with -P option. Since it displays the physical path of current working directory after resolving symbolic links. Hence we need to create a symbolic link to test.

  • Create a symbolic link of current directory, hit ln -s . d1symbolic
    Create symbolic link in linux using ln command
  • Navigate to the newly created symbolic link, hit cd d1symbolic.
    cd command in linux
  • Now if you do pwd or pwd -L, the output will be the full pathname without resolving symbolic link.
    pwd-l command linux
  • However, if you do pwd -P then it will print current working directory path after resolving symbolic link.
    pwd-p command linux

Feel free to drop you comments suggestions in comments section.

Happy coding 😉

About Bandna Paikaray

Bandna Paikaray is a teacher by profession and doing MCA from IGNOU. Optimistic and enthusiastic also have keen interest in painting and singing, which comes in the first place for her. She enjoy her own company. She believe in being real to yourself and others also. She always appreciate and admire creativity. Except this reading and writing is also what she like the most and can spend hours without getting bored. In her views being creative is the main key to think out of the box and explore more and more.

Follow on:

Comments and discussion
Have a doubt, write here. I will help my best.
Before commenting you must escape your source code before commenting. Paste your source code inside
<pre><code> ----Your Source Code---- </code></pre>