Open In App
Related Articles

pwd Command in Linux with Examples

Improve Article
Save Article
Like Article

pwd stands for Print Working Directory. It prints the path of the working directory, starting from the root. pwd is shell built-in command(pwd) or an actual binary(/bin/pwd). $PWD is an environment variable that stores the path of the current directory. This command has two flags.

Syntax of `pwd` command in Linux


This command doesn’t have any arguments or options, but it can accept flags for specific behavior. 

Flags For Specific behavior in `pwd` command in Linux.

  • The “-L” flag resolves symbolic links and prints the path of the target directory.
  • The default behavior of the shell built-in “pwd” is equivalent to using “pwd -L”.
  • Mention the “-P” flag, which displays the actual path without resolving symbolic links.
  • The default behavior of the binary “/bin/pwd” is the same as using “pwd -P”

pwd -L: Prints the symbolic path. 

pwd -P: Prints the actual path.

Example of `pwd` command.

A) Built-in pwd (pwd):

 Built-in pwd (pwd):

 Built-in pwd (pwd):

In the given example the directory /home/shital/logs/ is a symbolic link for a target directory /var/logs/ 

B) Binary pwd (/bin/pwd):

Binary pwd (/bin/pwd):

Binary pwd (/bin/pwd):

The default behavior of Built-in pwd is the same as pwd -L. Using “pwd -L” to obtain the symbolic path of a directory containing a symbolic link.

 The default behavior of /bin/pwd is the same as pwd -P. Utilizing “pwd -P” to display the actual path, ignoring symbolic links.

 The $PWD Environment variable. 

The significance of the $PWD environment variable describes how it stores the path of the current working directory.



 The $PWD variable value is the same as pwd -L.


In this article we have discussed the purpose and usage of the `pwd` command in Linux. We also learned about that how `-L` and `-P` flags affect the Output. In the end we have discussed the $PWD environment variable used for storing the current directory path.

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 09 Jun, 2023
Like Article
Save Article
Similar Reads
Related Tutorials